Send Mail WithAttachments
Function SendMCFMailWithAttach(&sFrom As string, &sSubject As string, &sEmail_BODY As string, &sMAIL_FILES As string, &sFileName As string) Returns number
Local PT_MCF_MAIL:MCFMultipart &multipartobj = create PT_MCF_MAIL:MCFMultipart();
Local PT_MCF_MAIL:MCFOutboundEmail &sendmailobj = create PT_MCF_MAIL:MCFOutboundEmail();
Local PT_MCF_MAIL:MCFBodyPart &htmlpart = create PT_MCF_MAIL:MCFBodyPart();
Local integer &sendstatus;
SQLExec("SELECT EMAILID FROM PSUSEREMAIL a where OPRID=:1 and EMAILTYPE='BUS' and PRIMARY_EMAIL='Y'", %UserId, &sEMAILID);
If All(&sEMAILID) Then
Else
&Email_Ids = &sEMAILID; /*Default Emaild*/
End-If;
If All(&sFrom) Then
&sendmailobj.From = &sFrom;
End-If;
&sendmailobj.Subject = &sSubject;
&sendmailobj.Recipients = &sEMAILID;
&htmlpart.Text = &sEmail_BODY;
&htmlpart.ContentType = "text/html";
If All(&sMAIL_FILES) Then
&htmlpart.AttachmentURL = &sMAIL_FILES;
&htmlpart.FileName = &sFileName;
&htmlpart.FilePathType = %FilePath_Absolute;
End-If;
&multipartobj.AddBodyPart(&htmlpart);
&sendmailobj.MultiPart = &multipartobj;
&sendmailobj.ContentType = "text/html";
If All(&sEMAILID) Then
&sendstatus = &sendmailobj.Send();
Else
MessageBox(0, "", 0, 0, "*** NO USER NOTIFICATION SETUP ***");
End-If;
Return &sendstatus;
End-Function;
No comments:
Post a Comment