Send Email through Code using Late Bound MSCRM 2011


If you want to send mail through sdk using late bound you can use below function

 private void CreateMail(IOrganizationService service,Guid _ contactid,Guid _From)

{

//create activityparty

Entity Fromparty = new Entity(“activityparty”);

Entity Toparty = new Entity(“activityparty”);

 //set partyid

//You can refer http://msdn.microsoft.com/en-us/library/gg328549.aspx to get acitivity party entity attribute

Toparty[“partyid”]= new EntityReference(“contact”, _ contactid));

 Fromparty[“partyid”]= new EntityReference(“systemuser”, _From));

//create email  and set attributes

Entity _Email = new Entity(“email”);

 _Email[“from”] = new Entity[] { Fromparty };

 _Email[“to”] = new Entity[] { Toparty };

 _Email[“directioncode”] = true;

 _Email[“regardingobjectid”] = new EntityReference(“contact”, _contactid);

  Guid EmailID = service.Create(_Email);

}

Enjoy !!!

Advertisements

Leave a comment

Filed under MS CRM 2011

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s