PeopleCode 发送邮件并给邮件添加附件

来源:互联网 发布:java 启动openssl 编辑:程序博客网 时间:2024/04/29 20:24
  1. import PT_MCF_MAIL:*;

  2. Local PT_MCF_MAIL:MCFOutboundEmail &email = 
  3. create PT_MCF_MAIL:MCFOutboundEmail();

  4. &email.From = &FromAddress;
  5. &email.Recipients = &ToList;
  6. &email.Subject = &Subject;

  7. Local string &plain_text = "Hi there!";
  8. Local PT_MCF_MAIL:MCFBodyPart &text = create PT_MCF_MAIL:MCFBodyPart();
  9. &text.Text = &plain_text;

  10. Local PT_MCF_MAIL:MCFBodyPart &attach1 = create PT_MCF_MAIL:MCFBodyPart();
  11. &attach1.SetAttachmentContent("Ocean Wave.jpg", %FilePath_Relative, 
  12. "Ocean Wave.jpg", "Ocean Wave", "", "");
  13. /* %FilePath_Relative indicates the file is available at Appserver's FILES?
  14. dierctory */

  15. Local PT_MCF_MAIL:MCFBodyPart &attach2 = create PT_MCF_MAIL:MCFBodyPart();
  16. &attach2.SetAttachmentContent("///file:C:/User/Documentum/XML%20Applications?
  17. /proddoc/peoplebook_upc/peoplebook_upc.dtd",
  18. %FilePath_Absolute, "Sample.jpg", "Sample", "", "");
  19. /* The Sample.jpg is available in the "public" folder of my-server machine*/


  20. Local PT_MCF_MAIL:MCFMultipart &mp = create PT_MCF_MAIL:MCFMultipart();
  21. &mp.AddBodyPart(&text);
  22. &mp.AddBodyPart(&attach1);
  23. &mp.AddBodyPart(&attach2);

  24. &email.MultiPart = ∓

  25. Local integer &res = &email.Send();

  26. Local boolean &done;

  27. Evaluate &resp
  28. When %ObEmail_Delivered
  29. /* every thing ok */
  30. &done = True;
  31. Break;

  32. When %ObEmail_NotDelivered
  33. /*-- Check &email.InvalidAddresses, &email.ValidSentAddresses
  34. and &email.ValidUnsentAddresses */
  35. &done = False;
  36. Break;

  37. When %ObEmail_PartiallyDelivered
  38. /* Check &email.InvalidAddresses, &email.ValidSentAddresses
  39. and &email.ValidUnsentAddresses; */
  40. &done = True;
  41. Break;

  42. When %ObEmail_FailedBeforeSending
  43. /* Get the Message Set Number, message number;
  44. Or just get the formatted messages from &email.ErrorDescription,
  45. &email.ErrorDetails;*/

  46. &done = False;
  47. Break;
  48. End-Evaluate;
原创粉丝点击