Header Ads

  • Recent Posts

    Sending HTML embedded emails using SENDMAIL function.

    It is not possible to send HTML embedded emails using PeopleSoft standard Workflow Technologies. However it is possible to send HTML embedded emails using SENDMAIL function.

    All About SENDMAIL function:
    Below is what is specified in PeopleBooks on SENDMAIL function. After the end of the transcript on SENDMAIL function I have mentioned my learning and findings of using this function.

    SendMail(flags, recipients, CCs, BCCs, subject, text,[, attachment_filenames][, attachment_titles] [,Mail_From] [,mail_sep] [, Content_Type] [,Reply_To] [,Sender])

    Use the SendMail function to send an email message from a PeopleSoft page. The APIs that support these subsystems must be present on the system for the function to work.
    Note. The code that actually calls SendMail determines the run location, not the originating code.

    The function sends a message using standard mail options, including recipient, CC, BCC, subject, and the text of the note. The message can include attached files, for which you supply fully qualified file names (that is, file names with paths) and titles (which appear in place of the fully qualified filename in the message). In addition, you can specify a Mail_From , which identifies the source email address. You can also use the Reply_To parameter to specify the email address to be used by the recipient for replying, which should be different than the Mail_From address.
    The flags parameter of this function and its return codes are platform dependent: the SMTP mail API ignores any additional flags. For this reason, SendMail should be used only in customizations that run on a known platform, if it is used at all. The preferred, platform-independent method for sending email from PeopleCode is to define an email routing as part of a business event, then trigger the business event using the TriggerBusinessEvent function.

    For workflow, in the activity email routing, you can specify the field map for Reply_To and Sender.


    An integer value passed directly to the mail system API to control mail system options. The value passed in this parameter is platform-dependent. The SMTP mail API ignores this parameter.

    A string consisting of a semicolon-separated list of email addresses containing the names of the message’s primary recipients.

    A string consisting of a semicolon-separated list of email addresses that are sent copies of the message.

    A string consisting of a semicolon-separated list of email addresses that are sent copies of the message. These recipients won’t appear on the message list.

    A string containing the text that appears in the message’s Subject field.

    The text of the message.

    A string consisting of a semicolon-separated list of fully qualified filenames, containing the complete path to the file and the filename itself.

    Another semicolon-separated list containing titles for each of the files provided in the attachment_filenames parameter. The titles appear near the attachment icons in place of the fully qualified filename.

    A string used to populate the 'reply-to' field. If this parameter isn't specified, the sender address from application server configuration file is used.
    My Observation: This email id need not be a valid email address and this can also be a string field.

    Specify the delimiter to be used to separate one email address from another. The default value is a semicolon (;).

    Specify the content type of the email as a string. The default value is plain text.

    If you want to specify HTML, you should use the following:
    Content-type: text/html; charset=utf8

    Specify the email address that the receiver should use when replying to this email instead of the Mail_From value.

    Specifies who the email is from, as a string. This may be different than the values specified for Mail_From or Reply_To parameters.

    Returns a Number value, which, if not one of the following general return codes, is platform-dependent.
    Return Code 0 signifies 'No Error' while -1 denotes 'No mail interface installed'.

    The following example sets up several variables that are then used to construct an email message that includes two attachments:

    &MAIL_FLAGS = 0;
    &MAIL_TO = "dduffield@peoplesoft.com;sweet_pea@peoplesoft.com";
    &MAIL_CC = "";
    &MAIL_BCC = "mom@aol.com";
    &MAIL_SUBJECT = "Live long and prosper!";
    &MAIL_TEXT = "Please read my attached CV. You will be amazed and hire me forthwith.";
    &MAIL_FILES = "c:\mydocs\resume.doc;c:\mydocs\coverlet.doc";
    &MAIL_SENDER = "MyEmail@Yahoo.com";

    if not (&RET = 0) then
     WinMessage("Return status from mail = " &RET);

    I used the below syntax to send an email function:
    SendMail(&MAIL_FLAGS, &emp_emailid, &MAIL_CC, &MAIL_BCC, &MAIL_SUBJECT, &MAIL_TEXT, &MAIL_FILES, &MAIL_TITLES, &MAIL_SENDER, "Content-type: text/html;");

    Below is the email that got sent with html tags- html, pr, br...
    All the tags as posted in the Message Catalog gets sent in the same way as text instead of resolving the html tags. Pasting html tags automatically gets resolved in blogger and I am not having the patience to debug it. The essence is html tabs do not get resolved properly if Content type is not defined properly.
    The email I got(html tags gets resolved in blogger):

    Please do not reply to this automatic notification. Contents in paragraph header Uniqueid. Contents inside the paragraph. Final email contents.

    I actually wanted a HTML format email and hence had used html tags in message catalog used to send this email. I spotted a minor difference which did not send the email in HTML format and instead caused to send the email with html tags as text.

    SendMail(&MAIL_FLAGS, &emp_emailid, &MAIL_CC, &MAIL_BCC, &MAIL_SUBJECT, &MAIL_TEXT, &MAIL_FILES, &MAIL_TITLES, &MAIL_SENDER, ";", "Content-type: text/html;");

    Please do not reply to this automatic notification.

    Contents in paragraph header Uniqueid. Contents inside the paragraph.

    Final email contents.


    1. Do you know how the message catalog can be written to display special characters? I'm using a message for the password expiration and any special characters are appearing as upside-down '?'. Thanks, John

    2. I'm facing the same issue.. anyone having any thoughts on this?

    3. Hello,

      I am currently developping an App Engine having peoplecode to launch a Crystal report (through process scheduler). A new process instance is created for the Crystal report which is initially in status Queued.
      The problem is that the Crystal waits for the App Engine to complete and then it starts processing.

      How can I make the crystal to start processing even though the AE has not ended yet?

      The reason is that i need to send the report generated by the crystal by email (usng the sendmail function.

      Thanks in advance

    4. Wow Shyam,

      I cant thank you enough for this post. The tib about using the ";", in the paremeters for Sendmail saved my life.

    5. Anyone know if this works on Tools 8.20

    6. Thanks shyam, can we use sendmail() on windows server also?

    7. Thanks for sharing that tip to include the separator ";" in the SendMail. That helped format the message catalogue entries with html tags.

    8. Hi Shyam,

      Thank You so much.. I was able to resolve HTML code in my generic email template:) Please keep posting such useful blogs. It made my day!!


    Please refrain for marketing messages and unnecessary back links.

    Post Top Ad

    Post Bottom Ad