locked
Track Emails from a separate application RRS feed

  • Question

  • Hello

    My client has a number of web applications and windows services that currently sends emails to its customers about (membership renewals, order confirmation etc).  The majority of the applications are written in ASP.NET/C#

    I was wondering is it possible to somehow track the emails that are sent back to the CRM?

    Any suggestions welcome.

    Many thanks.

    Wednesday, April 6, 2011 7:49 PM

Answers

  • Hi Geordie,

    If you do not want that email to go out and to see that in the history, instead of using 'SendEmailRequest' use "SetStateDynamic" request. here is the sample code for that.

                    SetStateDynamicEntityRequest req = new SetStateDynamicEntityRequest();
                    req.Entity = new Microsoft.Crm.Sdk.Moniker("email", emailGUID);
                    req.State = "completed";
                    req.Status = -1;

                    //Executing the request.
                   SetStateDynamicEntityResponse res = (SetStateDynamicEntityResponse)Service.Execute(req);

    Thanks and Regards

    Ramu

    Osmosys

    Osmosee's Blog

    • Marked as answer by geordie_123 Thursday, April 14, 2011 2:08 PM
    Thursday, April 14, 2011 1:42 PM

All replies

  • can you please explain your scenario ?


    cheers, S.Khan MCTS
    Thursday, April 7, 2011 2:26 AM
  • From your request I understand this.

    You are sending emails using ASP.NET/C# code to send your emails. Suppose if that recipient replies to those emails, you want those emails back in CRM. Right?

    For this you can use Email Router, Create an Incoming profile (In this you need to specify the details of your email account details including incoming port number) and use that to track the incoming mails to that user. For this you need to set the Access type for Emails for that user to "Email router" in user record.

    Please follow the article below to do this.

    http://blogs.msdn.com/b/crm/archive/2009/12/21/how-to-configure-microsoft-dynamics-crm-4-0-e-mail-router-on-premise-with-microsoft-exchange-server-2010.aspx

    Thanks and Regards

    Ramu

    Osmosys

    Osmosee's Blog


    • Proposed as answer by Janu_m Thursday, April 7, 2011 2:42 AM
    • Edited by Janu_m Thursday, April 7, 2011 3:07 AM just correcting a sentence.
    Thursday, April 7, 2011 2:42 AM
  • @Ramu

    Thanks for your reply.

    What I actually want to track is the emails sent (outgoing email) by the custom ASP.NET/C# application in the first place.

    I know how to use the email router to track incoming emails.

     

    Thursday, April 7, 2011 9:52 AM
  • Hi Geordie,

    Are you creating email record in CRM and sending that using "SendEmailRequest" ?

    If not for tracking your emails in CRM, please follow these steps.

    a) Configure outgoing email for the CRM user account or queue in Email Router.

    b) Create CRM email through code with all the required details.

    c) Send that by using 'SendEmailRequest'

    then your email will be sent and tracked in CRM.

    Thanks and Regards

    Ramu

    Osmosys

    Osmosee's Blog

    • Proposed as answer by Janu_m Friday, April 8, 2011 2:42 AM
    Thursday, April 7, 2011 12:29 PM
  • You could send the e-mail as usual, but then create an e-mail record in CRM via the SDK and set its statecode as completed. I've also seen various marketing automation services that send e-mails and document them in CRM as tasks.
    Thursday, April 7, 2011 1:30 PM
  • Hi,

    In that case you can just create email activity with outgoing direction through your ASP.NET C# application.

    send an email through your code and then create crm email activity record with appropriate details.


    cheers, S.Khan MCTS
    Thursday, April 7, 2011 11:35 PM
  • I don't suppose anyone has an example of SendEmailRequest functionality?

    Thanks in advance.

    Friday, April 8, 2011 1:21 PM
  • Hi Geordie,

    here is the sample code for this.

    // Create a SendEmail request.

     

    SendEmailRequest req = new SendEmailRequest();

    req.EmailId = emailId; //Guid of your CRM email record.

    req.TrackingToken =

    "";

    req.IssueSend =

    true;

     

    // Send the email message.
     

     

    SendEmailResponse res = (SendEmailResponse)_CS.Execute(req);

     

    Thanks and Regards

    Ramu

    Osmosys

    Osmosee's Blog

     

     

     

    • Proposed as answer by Janu_m Friday, April 8, 2011 7:02 PM
    Friday, April 8, 2011 7:01 PM
  • Hi All,

    Thanks so much for all of your comments.  My problem at the moment is that the existing web applications are critical and I do not want to introduce code that will cause these systems to slow down or worse crash when calling the crmservice for example.

    As a workaround to get the emails tracked without having to do much code change what about the following scenario:

    1. Create an new email address called crmemails@mycompany.com
    2. Create a forward mailbox
    3. Create a rule on crmemails@mycompany.com to forward all mail received as an attachment to the forward mailbox
    4. The forward mailbox will then process the email and add it to the relevant crm account/contact

    Your thoughts are most welcome.

    Tuesday, April 12, 2011 9:39 AM
  • @Janu_m

    Can you expand the above code so i can see how to actually create the email and set the To, From, Cc, Subject and body?

    Also, would i be able to create a workflow based on these emails being created?

    Wednesday, April 13, 2011 1:54 PM
  • Hi Geordie,

    Here is a link to create and send email programmatically.

    http://stackoverflow.com/questions/5378731/using-crm-4-0-sdk-to-send-emails-to-multiple-contacts-at-once

    Hope this helps.

     

    Thanks and Regards

    Ramu

    Osmosys

    Osmosee's Blog

    Wednesday, April 13, 2011 4:02 PM
  • Hi Ramu

    Thanks for the reply. One thing i might not have made clear from the start is that i don't want to resend the email.  I just need to create the email activity so it appears in the history of a contact record as being sent.

    Does this code actually send the email message again?

    Thanks in advance.

    • Marked as answer by geordie_123 Thursday, April 14, 2011 2:08 PM
    • Unmarked as answer by geordie_123 Thursday, April 14, 2011 2:08 PM
    Thursday, April 14, 2011 1:32 PM
  • Hi Geordie,

    If you do not want that email to go out and to see that in the history, instead of using 'SendEmailRequest' use "SetStateDynamic" request. here is the sample code for that.

                    SetStateDynamicEntityRequest req = new SetStateDynamicEntityRequest();
                    req.Entity = new Microsoft.Crm.Sdk.Moniker("email", emailGUID);
                    req.State = "completed";
                    req.Status = -1;

                    //Executing the request.
                   SetStateDynamicEntityResponse res = (SetStateDynamicEntityResponse)Service.Execute(req);

    Thanks and Regards

    Ramu

    Osmosys

    Osmosee's Blog

    • Marked as answer by geordie_123 Thursday, April 14, 2011 2:08 PM
    Thursday, April 14, 2011 1:42 PM
  • hi Ramu,

    Thanks you very much for that code.

    You have been most helpful.

     

    Thursday, April 14, 2011 2:08 PM