a) MsgToList
b) MsgSubject
c) MsgBody
d) CommProfile
Here below is the working example for the same:
var inp = TheApplication().NewPropertySet();
var out = TheApplication().NewPropertySet();
var svc = TheApplication().GetService("Outbound Communications Manager");
inp.SetProperty("CommProfile", "SiebelMantra Profile");
inp.SetProperty("MsgToList", siebelmantra@gmail.com);
inp.SetProperty("MsgSubject", "Test Email");
inp.SetProperty("MsgBody", "This is a test email");
svc.InvokeMethod("SendMessage", inp, out);
Here below is the email I received:
So, everything is working as desired, but what if you are required to send a HTML email which contains text with different colors and formatting? Well, one can quickly answer that you can use "MsgHTMLBody" argument in the above code instead of using "MsgBody". Yes, that is correct but the only it got is that you need to pass the complete HTML code as the value to this argument, but wait a minute why to take all this pain when Siebel provides a mechanism to keep the email template in HTML format for you and just need to create it from the UI. Yes, you guessed it right, I am talking about Administration - Communications -> All Templates view.
Just create a new Email Template with :
a) Status = Active
b) HTML Template = True
Now, here below is the small code to make this work:
var inp = TheApplication().NewPropertySet();
var out = TheApplication().NewPropertySet();
var svc = TheApplication().GetService("Inbound E-mail Database Operations");
inp.SetProperty("BusObj", "Comm Package");
inp.SetProperty("BusComp", "Comm Package");
inp.SetProperty("Name", "Test");
inp.SetProperty("QueryFields", "Name");
inp.SetProperty("ValueFields", "Template Text");
svc.InvokeMethod("FindRecord", inp, out);var inp1 = TheApplication().NewPropertySet();
var out1 = TheApplication().NewPropertySet();
var svc1 = TheApplication().GetService("Outbound Communications Manager");
inp1.SetProperty("CommProfile", "SiebelMantra Profile");
inp1.SetProperty("MsgToList", siebelmantra@gmail.com);
inp1.SetProperty("MsgSubject", "Test Email");
inp1.SetProperty("MsgHTMLBody", out.GetProperty("Template Text"));
svc1.InvokeMethod("SendMessage", inp1, out1);
and when I executed the above code, here below is the email in HTML format I received in my Inbox:
Yes .really nice post. in addition if we want to send some pictures in mail that can also be done by adding those in template items.
ReplyDeleteHi,
ReplyDeleteI'm trying this code and indeed the mail is sent in HTML but the Substitution Fields are not picking up the value in the BC. They remain as "[BCName.BCField]". Is this the expected behavior?
Thx and congratulations for the blog.
Duarte, in order to substitute fields, instead of
ReplyDeletesvc1.InvokeMethod("SendMessage".....
you have to use
svc1.InvokeMethod("CreateRequest", ....
Hi ,
ReplyDeleteI am trying to send an email with 1)tachment 2)table structure in body.
Since attachment is not possible with 'Create Request' method I tried using 'SendMessage'.But in the body i can see html code i.e. tags "tr " and "td" etc are still visible. This is even after using above solution. Can you please suggest what I need to do.
make sure you use "MsgHTMLBody" input argument
DeleteReally Nice Information,Thank You Very Much For Sharing.
ReplyDeleteWeb Development Company