Creating Email Attachments by Specifying URLs
The following code example creates two email attachments by specifying a URL for each file location instead of an absolute or relative path to the file.
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("http://example.com/index.htm", %FilePath_Absolute, "example.html", "An Example", "", "");
Local PT_MCF_MAIL:MCFBodyPart &attach2 = create PT_MCF_MAIL:MCFBodyPart();
&attach2.SetAttachmentContent("ftp://www.w3c/docs/somedoc.htm", %FilePath_Absolute, "somedoc.htm", "somedoc from w3c", "", "");
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
&done = False;
MessageBox(0, "", &email.MessageSetNumber, &email.MessageNumber, "PeopleTools error not found", &email.GetErrorMsgParam(1), &email.GetErrorMsgParam(2));
Break;
When %ObEmail_PartiallyDelivered
&done = True;
Break;
When %ObEmail_FailedBeforeSending
&done = False;
MessageBox(0, "", &email.MessageSetNumber, &email.MessageNumber, "PeopleTools error not found", &email.GetErrorMsgParam(1), &email.GetErrorMsgParam(2));
Break;
End-Evaluate;