PeopleCode 发送邮件并给邮件添加附件
来源:互联网 发布:java 启动openssl 编辑:程序博客网 时间:2024/04/29 20:24
- import PT_MCF_MAIL:*;
- Local PT_MCF_MAIL:MCFOutboundEmail &email =
- create PT_MCF_MAIL:MCFOutboundEmail();
- &email.From = &FromAddress;
- &email.Recipients = &ToList;
- &email.Subject = &Subject;
- Local string &plain_text = "Hi there!";
- Local PT_MCF_MAIL:MCFBodyPart &text = create PT_MCF_MAIL:MCFBodyPart();
- &text.Text = &plain_text;
- Local PT_MCF_MAIL:MCFBodyPart &attach1 = create PT_MCF_MAIL:MCFBodyPart();
- &attach1.SetAttachmentContent("Ocean Wave.jpg", %FilePath_Relative,
- "Ocean Wave.jpg", "Ocean Wave", "", "");
- /* %FilePath_Relative indicates the file is available at Appserver's FILES?
- dierctory */
- Local PT_MCF_MAIL:MCFBodyPart &attach2 = create PT_MCF_MAIL:MCFBodyPart();
- &attach2.SetAttachmentContent("///file:C:/User/Documentum/XML%20Applications?
- /proddoc/peoplebook_upc/peoplebook_upc.dtd",
- %FilePath_Absolute, "Sample.jpg", "Sample", "", "");
- /* The Sample.jpg is available in the "public" folder of my-server machine*/
- Local PT_MCF_MAIL:MCFMultipart &mp = create PT_MCF_MAIL:MCFMultipart();
- &mp.AddBodyPart(&text);
- &mp.AddBodyPart(&attach1);
- &mp.AddBodyPart(&attach2);
- &email.MultiPart = ∓
- Local integer &res = &email.Send();
- Local boolean &done;
- Evaluate &resp
- When %ObEmail_Delivered
- /* every thing ok */
- &done = True;
- Break;
- When %ObEmail_NotDelivered
- /*-- Check &email.InvalidAddresses, &email.ValidSentAddresses
- and &email.ValidUnsentAddresses */
- &done = False;
- Break;
- When %ObEmail_PartiallyDelivered
- /* Check &email.InvalidAddresses, &email.ValidSentAddresses
- and &email.ValidUnsentAddresses; */
- &done = True;
- Break;
- When %ObEmail_FailedBeforeSending
- /* Get the Message Set Number, message number;
- Or just get the formatted messages from &email.ErrorDescription,
- &email.ErrorDetails;*/
- &done = False;
- Break;
- End-Evaluate;