Bhubaneswar, Odisha, India
+91-8328865778
support@softchief.com

Send Email using C# Code Sample in Dynamics 365

Send Email using C# Code Sample in Dynamics 365

Emails are the mostly used communication media in all types of industries. Microsoft Dynamics has a very flexible way to deal with Email activities. Emails are stored as an Activity record in Dynamics 365 CRM. Any business process, which requires to send emails first creates an email activity record in the system then by email router or email exchange server the email send to target users.

This code explains how to send emails using C# in Dynamics 365 CRM.

// Create the 'From:' activity party for the email            
ActivityParty fromParty = new ActivityParty            
{                
PartyId = new EntityReference(SystemUser.EntityLogicalName, _userId)            };
// Create the 'To:' activity party for the email

ActivityParty toParty = new ActivityParty

{

PartyId = new EntityReference(“contact”, _contactId) //Pass your required mail to record info

};

// Create an e-mail message.

Email email = new Email

{

To = new ActivityParty[] { toParty },

From = new ActivityParty[] { fromParty },

Subject = "SDK Sample e-mail",

Description = "SDK Sample for SendEmail Message.",

DirectionCode = true

};

_emailId = _serviceProxy.Create(email);