Hi,
am using a custom aspx page developed in C# to send email using template from lead entity..
- using the proxy authentication with logged in systemuserid
- email owner and from parameter taking the correct user - "systemuser"
- template is having user address, phone number, email parameters to display as signature - these parameters are reading on wrong systemuser
below is the code in place ...
Entity email = new Entity();
email.LogicalName = "email";
email["ownerid"] = new EntityReference("systemuser", new Guid(userId));
EntityReference regardingObject = new EntityReference("lead", new Guid(LeadId));
email.Attributes.Add("regardingobjectid", regardingObject);
EntityReference from = new EntityReference("systemuser", new Guid(userId));
//EntityReference to = new EntityReference("systemuser", new Guid(ToUserId));
EntityReference to = new EntityReference("lead", new Guid(LeadId));
Entity fromParty = new Entity("activityparty");
fromParty.Attributes.Add("partyid", from);
Entity toParty = new Entity("activityparty");
toParty.Attributes.Add("partyid", to);
EntityCollection collFromParty = new EntityCollection();
collFromParty.EntityName = "systemuser";
collFromParty.Entities.Add(fromParty);
EntityCollection collToParty = new EntityCollection();
collToParty.EntityName = "systemuser";
collToParty.Entities.Add(toParty);
email.Attributes.Add("from", collFromParty);
email.Attributes.Add("to", collToParty);
email.Attributes.Add("subject", "Welcome Email");
email.Attributes.Add("description", "Welcome Email");
SendEmailFromTemplateRequest emailUsingTemplateReq = new SendEmailFromTemplateRequest
{
Target = email,
TemplateId = new Guid(mnuDropStatusCode.SelectedValue.ToString()),
RegardingId = new Guid(LeadId),
RegardingType = "lead"
};
SendEmailFromTemplateResponse emailUsingTemplateResp = (SendEmailFromTemplateResponse)_serviceProxy.Execute(emailUsingTemplateReq);
Alby