Tuesday, 15 November 2016

Sending Images in e-mail's body part in PeopleSoft

Sending Images in e-mail's body part in PeopleSoft

Hi , now I have an requirement to send a e-mail , with my message body which should hold a logo of my organisation.

So how do I proceed with this ? There are two main stops involved in this .
 
1. Send the image as an attachment.
2. Embed the image(present as attachment) in the body part of the mail.

The above two options are the main criteria that you should follow to send the image in the body part in the mail.

One another important thing to be considered is , the image that you are going to send as an attachment should be present in the application server

Now we'll see things in detail, the follwing code will embed the attachment in the body part of the mail that is present.

import PT_MCF_MAIL:*; /*Delivered application Package in peoplesoft*/

Local PT_MCF_MAIL:MCFOutboundEmail &email = 
create PT_MCF_MAIL:MCFOutboundEmail();
  
   &email.From = &FromAddress; /*from address mail ids*/
   &email.Recipients = &ToList; /*To address mail ids*/
   &email.Subject = &Subject; /*Subject of the mail */
   

Local string &htmlText = 
"<html>" | 
"  <head><title></title></head>" | 
"  <body>" | 
"    <b>A sample jpg</b><br>" | 
"    <IMG SRC=cid:23abc@pc27 width=566 height=424><br>" | 
"    <b>End of jpg</b>" | 
"  </body>" | 
"</html>"; /*Header and body of the mail , where image is present in the body part*/


   
   Local PT_MCF_MAIL:MCFMultipart &mp = create T_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!", "", "");/*get the path of the image in the current environment*/
   
   &image.AddHeader("Content-ID", "<23abc@pc27>");
   
   &mp.AddBodyPart(&html);
   &mp.AddBodyPart(&image); /*The image is embedded here in the body part of the mail*/
   
   &email.MultiPart = &mp;
   
   Local integer &res = &email.Send(); /*send the mail */

No comments:

Post a Comment