Hi All,
I have written a code for sending mail using template and it is successfully working. I want attach a pdf while sending mail.
Need help.
Below are my source code:
try{
Entity Fromparty = new Entity("activityparty");
Fromparty["partyid"] = new EntityReference("systemuser", CreatedBy);
Entity email = new Entity("email");
email["from"] = new Entity[] { Fromparty };
email["to"] = entCollectionAsActivityPartyOfUsers;
email["directioncode"] = true;
Entity Template = null;
Template = GetGlobalTemplate("OBMS Test Email", service);
//Template = GetGlobalTemplate(Util.GetKeyValue(service, "eMailTemplate-Notification-AccountCreation"), service);
if (Template != null && Template.Id != null)
{
var emailUsingTemplateReq = new SendEmailFromTemplateRequest
{
Target = email.ToEntity<Entity>(),
TemplateId = Template.Id,
RegardingId = opportunityId,
RegardingType = "opportunity"
};
var emailUsingTemplateResp = (SendEmailFromTemplateResponse)service.Execute(emailUsingTemplateReq);
}
}
catch (FaultException<OrganizationServiceFault> ex)
{
throw ex;
}
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Thanks and Regards, Yogesh Vijay Mulay