Friday, July 1, 2011

How to send Email in HTML Format?...... contd

In continuation of the previous post, I found another good way to achieve the requirement of sending email in HTML format and moreover you are required to replace the field values dynamically from business component. So the extra information you need to provide to Outbound Communication Manager is the ROW_ID of the record in context.

Suppose, here below is the Email Template need to send in HTML format:


Here below is the code to achieve it:

var inp = TheApplication().NewPropertySet();
var out = TheApplication().NewPropertySet();
var svc = TheApplication().GetService("Outbound Communications Manager");
inp.SetProperty("CommProfileOverride", "SiebelMantra Profile");
inp.SetProperty("SourceBusObj", "Service Request");
inp.SetProperty("RecipientBusComp", "Service Request");
inp.SetProperty("SourceIdList", "1-B9PGUA");
inp.SetProperty("TestAddress", "siebelmantra@gmail.com");
inp.SetProperty("PackageNameList", "Test");
svc.InvokeMethod("CreateRequest", inp, out);



Here below is the email with necessary SR Number and status:


Siebel makes life "dynamically" colorful, isn't it ;)

12 comments:

  1. Can we attach files also to this email in anyway using workflow?

    ReplyDelete
  2. Hi Anonymous,

    Yes, you can attach as many files you want with the Email Template in "Administration - Communications -> All Templates -> Template Items" view. All the files you associate, will go as attachment in the email.

    Note, this will not provide you the flexibility of attaching different files in diff email like in "SendMessage" method with argument "AttachFileList".

    Cheers
    Gaurav

    ReplyDelete
  3. nice post gaurav.. thanks you for sharing with us.

    ReplyDelete
  4. Hi Gaurav,
    Great post.I am working on a requirement where we need to pass parameters to email templates. Creating multiple email templates is one option but i am in search of some mechanism where we can pass parameters from workflow to email templates just as we pass in Data Mappers. Let me know if you have encountered something like this before.

    Regards,
    -Rahul-

    ReplyDelete
  5. Hi,

    May i know how to attach or add the picture in the template? I have added the picture in the Template Item but i don't know how to put in Template. Anyone can help?

    ReplyDelete
  6. hello Gaurav....
    I have requirement to send attachment with the mail using the Create Request Method ... is there any way by which this can be done ??

    User can upload the attachment against the case , when the mail sent to user (using the predefined template) using CreateRequets methods the attachment agaisnt the case should be sent alongwith the mail , there will be diff attachement with diff cases....

    Can you please provide any inputs on this please??

    Thanks
    Rishikesh Bhise

    ReplyDelete
  7. Any updates on the question from Rishikesh?

    hello Gaurav....
    I have requirement to send attachment with the mail using the Create Request Method ... is there any way by which this can be done ??

    User can upload the attachment against the case , when the mail sent to user (using the predefined template) using CreateRequets methods the attachment agaisnt the case should be sent alongwith the mail , there will be diff attachement with diff cases....

    Can you please provide any inputs on this please??

    Thanks
    Rishikesh Bhise


    ReplyDelete
  8. Hi Rishikesh & Anonymous,

    Please note that using "CreateRequest", when you provide Email Template name in input argument "PackageNameList", system will automatically send the attachments tied with the template i.e. Administration - Communications -> All Templates -> Template Items view.

    So, these attachments are actually predefined and not dynamic.

    For your requirement, you might need to write customized BS to extract the attachment files tied with the Case and use "SendMessage" method for sending in an email.

    Cheers
    Gaurav

    ReplyDelete
  9. Thanks, Gaurav!

    Your thoughts on the customised BS that would be needed for the requirement? I do have an existing email template but would need to have the dynamic attachments included in the Outbound email.

    Thank.

    ReplyDelete
  10. Hi Anonymous,

    You can use BS: FINS Industry BC Facility Service, Method: GetFile to retreive the attachment and then invoke the SendMessage of OCM BS for send the email with attachment.

    Cheers
    Gaurav

    ReplyDelete
  11. Hi Gaurav,

    Great detailed post. I had a question though. I have a similar requirement as Rishikesh's.
    And I have to stick with "CreateRequest" method as the comm template I will be using has a HTML tags file to render the message body.

    Reason - I have to embed a dynamic link (which has an Id substitution) to a text. Eg. "Click Here" which will have a dynamic URL.
    I was not able to achieve this by adding the HTML body text as a simple/advanced template text area as you did in your example.

    The attachments I need to attach to the email are the case attachments which will defer for each outbound request as stated by Hrishikesh.

    I am finding a solution to implement either way -
    1. Adding the embedded url in the Compose Template text area, so that I can retrieve the attachments using customized Script and use SendMessage method.

    OR

    2. Attach the case attachments per outbound request as template item at run time(using customized scripts) and use CreateRequest method.
    The only issue I foresee here(2) is how can we handle concurrent outbound calls??
    Eg, If we have 2 simultaneous outbound requests for Case a with att1 and Case b with att2, is there a way to identify the attachments per request (case) at the Comm Template Item level and then send accordingly using CreateRequest???

    Your response is appreciated.

    Thanks.

    ReplyDelete
  12. Hi Rishikesh and VP,

    Thanks for your comments. I found your requirement worth sharing a post. Please refer the below link:

    http://siebelmantra.blogspot.com/2013/07/how-to-send-email-in-html-format-with.html

    Cheers
    Gaurav

    ReplyDelete