private void SendEmailToUnresolvedRecent(IOrganizationService prmCrmService, string prmToRecipientEmailAddress, Guid prmSenderUserId, string prmSubject, string prmMessageBody) { // Email record id Guid wod_EmailId = Guid.Empty; // Creating Email 'to' recipient activity party entity object Entity wod_EmailToReciepent = new Entity("activityparty"); // Creating Email 'from' recipient activity party entity object Entity wod_EmailFromReciepent = new Entity("activityparty"); // Assigning receiver email address to activity party addressused attribute //wod_EmailToReciepent["participationtypemask"] = new OptionSetValue(0); wod_EmailToReciepent["addressused"] = prmToRecipientEmailAddress; // Setting from user account wod_EmailFromReciepent["partyid"] = new EntityReference("systemuser", prmSenderUserId); // Creating Email entity object Entity wod_EmailEntity = new Entity("email"); // Setting email entity 'to' attribute value wod_EmailEntity["to"] = new Entity[] { wod_EmailToReciepent }; // Setting email entity 'from' attribute value wod_EmailEntity["from"] = new Entity[] { wod_EmailFromReciepent }; // Setting email subject and description wod_EmailEntity["subject"] = prmSubject; wod_EmailEntity["description"] = prmMessageBody; // Creating email record wod_EmailId = prmCrmService.Create(wod_EmailEntity); // Creating SendEmailRequest object for sending email SendEmailRequest wod_SendEmailRequest = new SendEmailRequest(); // Creating Email tracking token request object GetTrackingTokenEmailRequest wod_GetTrackingTokenEmailRequest = new GetTrackingTokenEmailRequest(); // Creating Email tracking token response object to get tracking token value GetTrackingTokenEmailResponse wod_GetTrackingTokenEmailResponse = null; // Setting email record if for sending email wod_SendEmailRequest.EmailId = wod_EmailId; wod_SendEmailRequest.IssueSend = true; // Getting tracking token value wod_GetTrackingTokenEmailResponse = (GetTrackingTokenEmailResponse) prmCrmService.Execute (wod_GetTrackingTokenEmailRequest); // Setting tracking token value wod_SendEmailRequest.TrackingToken = wod_GetTrackingTokenEmailResponse.TrackingToken; // Sending email prmCrmService.Execute(wod_SendEmailRequest); }
C# Code for Sending Email to Unresolved Recipients
This code will send email to unresolved recipient.