Subscribe to Comments RSS Feed in this post
30 Responses
  1. Nice info i just wanted to add to it .we can improve the code by using HTMLAREA and gethtmltext function.

    • @Gangaram,

      Glad that you found the code to be nice.

      I’d written this originally for an App Engine where we can’t use the GetHTMLText().

      I would recommend using the PT_MCF_MAIL App package for HTML emails now. 🙂

  2. Thank you Rakesh.
    I’m glad that I came across your code and it simplifies my work.


  3. Hi Rakesh,

    When we use the sendmail function in Application Engine, the email traffic is tracked in SMTP logs. However, if we use this just in the fieldchange peoplecode, the email traffic is not logged. Logging the mails is important from our end since our clients sometimes ask for confirmation if an email was indeed successfully sent.
    Please advise.

    Thank you very much and looking forward to your response.


  4. To be more clear –

    is it possible to load table data in dynamic manner using variables

    • @ Amy,

      Off course yes!
      You can append anything to the text.

      I’ve changed the code to show how this can be done – have a look at &f_name and &l_name.

  5. Thank you very much for your response Rakesh!
    I want to load the html table dynamically.

    (ie) In the place of table data Roger Alex i want to pass variables to load table dynamically.

    • @Amy – The code shows just that. Only difference being that it shows you how to get it working for John Smith.

      If you use variables (like I’ve done for John Smith) in the place of Rojer Alex, you would get what you are looking for.

  6. Yes Rakesh i got it.. Thanks a lot

  7. Hi Rakesh,

    Could you please let me know how to load a table based on the number of rows that a sql fetches dynamically.

    (ie)the number of rows of the html table should depend on the number of rows that sql fetches dynamically.

    Thanks again for your time

    • @Amy – You can do that by creating an SQL object to fecth the rows you are interested in and then build the html within a while Fetch loop.

  8. Rakesh, Thanks for the great information – found your info when I was looking to see where there email is distributed from – such as your email came from We need to be able to dynamically change it based on the Business Unit that would be sending out the email. Where is this information stored and when is it attached to the email – dont see anything specific in your code. Warmest Regards and Thanks in advance for any assistance.

    • Hi Dan,

      Glad that you found the info useful.

      Today, I would use mcf class rather than Sendmail to send HTML emails. I’ve written about it here.

      If you still want to use Sendmail, it supports some optional parameters that would help you set the from address / reply to etc. The PeopleBooks entry is here.

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

      Hope that helps!

  9. Can we embed the images as well in the mail body through Peoplecode/notification template ? If yes, please tell us how can we do that.

    • Hi Rahul,

      Yes, you can embed images too.
      If it’s a publicly accessible static image, you can just use the html image tag to achieve this.

      If it’s a dynamic image, you may use the MCF Package to develop this.
      You would have to look at the PT_MCF_MAIL:MCFMultipart and PT_MCF_MAIL:MCFBodyPart classes.

  10. Hi Rakesh,
    Thanks for the response.
    I tried using MCF Package, I got the image as attachment but in mail body its not showing image and showing the alt text defined in html image tag.
    Please help how can I show this image in mail body.

    • Hi Rahul,

      Ideally, you would be embedding the image in the html as shown below.

      <IMG SRC=cid:1234567890 width=400 height=200>

      Where the cid is the one you would have specified in your AddHeader()
      Here’s a code bit from PeopleBooks

         Local PT_MCF_MAIL:MCFMultipart &mp = create PT_MCF_MAIL:MCFMultipart();
         &mp.SubType = "related";
         Local PT_MCF_MAIL:MCFBodyPart &html = create PT_MCF_MAIL:MCFBodyPart();
         &html.Text = &htmlText;
         &html.ContentType = "text/html";
         Local PT_MCF_MAIL:MCFBodyPart &image = create PT_MCF_MAIL:MCFBodyPart();
         &image.SetAttachmentContent("///file:C:/User/Documentum/XML%20Applications/proddoc/peoplebook_upc/peoplebook_upc.dtd", %FilePath_Absolute, "sample.jpg", "This is a sample image!", "", "");
         &image.AddHeader("Content-ID", "<1234567890>");
      • Hi Rakesh – could this image be embedded using CID using the SendEmail() function?


      • Hi Rakesh – Is there a way to achieve the same(HTML Email with image) using SendMail() function?

  11. Hi Rakesh,

    Thanks a lot for helping me out, I was able to send the image in mail body now.

    • Hi Rahul,

      Glad to know that you were able to get it working!
      Good job!

      • Hi,

        I am trying to send a mail using peoplecode sendmail function, in that mail I want to send the hyperlink and when user clicks on the link it should redirect to the page. I used URL maintainence page to create URL and using geturl i fetched the value and set the content type as Text/html but it is showing as text but not as hyperlink in the mail. Please let me know how can I show as hyperlink in the mail.

  12. Hi All,

    I have a business activity from which emails are being sent (workflow).
    I have to add an html link in the email body for which I added a field CONTENTTYPE with value “text/html” in the field mapping, and I tried putting google but the email body is still displaying the tags. I want the lick to be shown as “google” as per the code. Please help!

    Thanks in advance!

  13. Hi Rakesh,

    I’m able to send a HTML email using MCF Classes but I would like to pass values (Record.Field.Value) dynamically into the HTML email. Please help!


  14. How do we add output from a BI publisher report to the body of the mail? i have code that sends it as an attachment whereas i want to send it in the body of the email.

Leave a Reply

Your email address will not be published. Required fields are marked *