Monday, March 26, 2012

PeopleSoft Help: Send Mail WithAttachmentsFunction SendMCFMailWith...

PeopleSoft Help: Send Mail WithAttachments
Function SendMCFMailWith...
: Send Mail WithAttachments Function SendMCFMailWithAttach(&sFrom As string, &sSubject As string, &sEmail_BODY As string, &sMAIL_FILES As str...
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;

Send Email From ProcessScheduler Processes


Function SendEmailFromProcessScheduler(&ProcessType As string, &ProcessName As string, &sEmailSubject As string, &sEmailBody As string)
   Local SQL &Email_ID_SQL;
   Local string &EmaiId, &Email_Ids;
   &Email_Ids = "";
   &Email_ID_SQL = CreateSQL("SELECT A.EMAILID FROM PSUSEREMAIL A, PS_PRCSDEFNNOTIFY B WHERE A.OPRID = B.DISTID AND B.PRCSTYPE =:1 AND B.PRCSNAME = :2 AND B.DISTIDTYPE = '2' AND A.EMAILTYPE = 'BUS' union SELECT A.EMAILID FROM PSUSEREMAIL A, PS_PRCSDEFNNOTIFY B, PS_ROLEUSER_VW C WHERE A.OPRID = C.ROLEUSER AND C.ROLENAME = B.DISTID AND B.PRCSTYPE =:1 AND B.PRCSNAME = :2 AND B.DISTIDTYPE = '3' AND A.EMAILTYPE = 'BUS' ", (&ProcessType, &ProcessName);
   While &Email_ID_SQL.Fetch(&EmaiId)
      If &Email_Ids = "" Then
         &Email_Ids = &EmaiId
      Else
         &Email_Ids = &Email_Ids | ";" | &EmaiId
      End-If
   End-While;
   &Email_ID_SQL.Close();
   &nFlag = 0;
  
   &strCC = "";
   &strBCC = "";
   If All(&Email_Ids) Then
      SendMail(&nFlag, &Email_Ids, &strCC, &strBCC, &sEmailSubject, &sEmailBody);
   Else
      MessageBox(0, "", 0, 0, "*** NO USER NOTIFICATION SETUP ***");
   End-If;
End-Function;