Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

CRM 2011 : Send email using template send successfully but reading wrong user parameters

$
0
0

Hi,

am using a custom aspx page developed in C# to send email using template from lead entity..

  1. using the proxy authentication with logged in systemuserid
  2. email owner and from parameter taking the correct user - "systemuser"
  3. 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


Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>