I need someone to please help me be able to send emails out from CRM using C# Plugin.There's so many bits and pieces out on the internet and I'm having trouble piecing it all together.
I was able to register the plugin and it's executing on the server, but having a hard time figuring out how to implement this part into the plugin.
Here's the rest of the code. I didn't correctly call the CreateMail( ) function, puzzled how to add the IOrg service and Contact Guid.
public class SendEmail { #region Class Level Members // Define the IDs needed for this sample. private Guid _emailId; private Guid _contactId; private Guid _userId; private OrganizationServiceProxy _serviceProxy; #endregion Class Level Members #region How To Sample Code /// <summary> /// Send an e-mail message. /// </summary> /// <param name="serverConfig">Contains server connection information.</param> /// <param name="promptforDelete">When True, the user will be prompted to delete all /// created entities.</param> public void Run(ServerConnection.Configuration serverConfig, bool promptforDelete) { try { // Connect to the Organization service. // The using statement assures that the service proxy will be properly disposed. using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,serverConfig.Credentials, serverConfig.DeviceCredentials)) { // This statement is required to enable early-bound type support. _serviceProxy.EnableProxyTypes(); // Call the method to create any data that this sample requires. CreateMail(); // Use the SendEmail message to send an e-mail message. SendEmailRequest sendEmailreq = new SendEmailRequest { EmailId = _emailId, TrackingToken = "", IssueSend = true }; SendEmailResponse sendEmailresp = (SendEmailResponse)_serviceProxy.Execute(sendEmailreq); Console.WriteLine("Sent the e-mail message."); } } // Catch any service fault exceptions that Microsoft Dynamics CRM throws. catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>) { // You can handle an exception here or pass it back to the calling method. throw; } }
*This post is locked for comments