locked
Email status is "draft" after making a SendEmailRequest call. RRS feed

  • Question

  • I am using a workflow to create an email.

    From the same workflow I use a custom assembly to add attachments to the email and send it.

     

    My issue is with the behavior of the SendEmailRequest as seen below.  When working correctly the email will have a status of "pending" or "sent". 

    However there are times that the email is stuck in the "draft" status.

    Any ideas as to why the email is stuck as "draft" after calling the SendEmailResponse message?

     

     

    ...   

    var req = new SendEmailRequest
                                  {
                                      EmailId = new Guid(emailId),
                                      TrackingToken = string.Empty,
                                      IssueSend = true
                                  };

     

                    try
                    {
                        var res = (SendEmailResponse) service1.Execute(req);
                       
                    }
                    catch (Exception ex)
                    {
                        string s = ex.Message;
                    }

    Wednesday, February 16, 2011 5:07 PM

Answers

  • Maybe you'd want to change the title of the thread to reflect the actual behavior. (change draft to pending).
    They are two different states and imply very different scenarios for an email.

    If the workflow were to leave it in the draft state, then that implies that the "Send" action in CRM did not complete.
    Pending state in CRM implies that the Send action in CRM is completed and a client (outlook/router) is yet to pick the emails for processing.

    w.r.t router :
     - How many CRM users/queues are configured in the email router?
     - What is the number of threads configured in router?
     - Are you configuring against Exchange Online?
     - How often is the workflow run?
     
    For more info, you can turn on logging in email router anc check to see that outgoing emails are being processed regularly.
    To do so :

     - In the Service folder of Email router installation, locate the file Microsoft.Crm.Tools.EmailAgent.xml.
     - There is a key for Log Level - <LogLevel></LogLevel> This is by default set to 1. Please set it to 3.
     - Add a key for Log file below this key. <LogFile>C:\Log.txt</LogFile> Mention the desired log file path and name.
     - Restart the Email router service.

    You should be able to see the statement ... checking for outgoing messages to process in.....
    once every 1 - 2 minutes.

    Thursday, March 3, 2011 2:39 AM

All replies

  • Could you please let us know as to what version of CRM you are using. CRM 4 or CRM 2011?

    You mentioned that you are adding attachments using the custom assembly. Is there any specific handling for a set of messages?
    You are using the SendEmailRequest to send the emails from CRM. Is there any exception logged when the email is not moved from Draft state to Pending Send State?

    Wednesday, March 2, 2011 3:34 AM
  • It could be that the email attachment is in the black list defined in (Settings -> System Settings).

    Are the recipients of the email resolved correctly? It could be that you have some unresolved email recipients and that the system setting to allow unresolved recipient is turned off. (Settings -> System Settings).
    Wednesday, March 2, 2011 3:39 AM
  • can you please check the email record and see if you see red flag in From or To column in the email, sometimes if these fields are not correct CRM will not send that email.

    so check the records that are remains in draft state and works successfully, compare both of them and that should provide you clue regarding resolving this isssue.


    MayankP
    My Blog
    Follow Me on Twitter
    Wednesday, March 2, 2011 10:17 AM
    Answerer
  • Thanks for your response!

    For testing purposes I have set the To / From to the same email address (myself).

    On the development server I've never had the problem with the emails being stuck in a "draft" state.

    On production, the workflow works correctly for a while and then eventually the emails stop being sent out.  Rebooting the server seems to allow the emails to be sent out correctly.

     

    Wednesday, March 2, 2011 6:52 PM
  • Thanks for your reply!

     

    I'm using CRM 4.0

     

    I'm not sure what you mean by a "specific handling".

     

    I've added logging to the catch block now and am not seeing any exceptions being thrown.  I'll continue to monitor that.

     

     

    Wednesday, March 2, 2011 6:55 PM
  • In both my development environment and production I set the To/From to myself.

    Thanks

    Wednesday, March 2, 2011 6:58 PM
  • since you set your self as from/to in email, check out what is setting for your user record in CRM regarding sending an crm email. is it email router or outlook client??

    if it is outlook client then you need to configure your outlook client to point to Live environment, becuase your outlook client may be connect to Dev so dev works fine.

    if your outlook client is configure to correct live environment then check outlook CRM options (CRM Menubar -> Options) Email tab and make sure outlook allow to send email from  CRM.

    if you are using email router then check if router is configured correctly or not..

    hope this helps..

     

     


    MayankP
    My Blog
    Follow Me on Twitter
    Wednesday, March 2, 2011 8:19 PM
    Answerer
  • The setting for my user record only uses the email router and nobody is changing it to anything else.

     

    When I deploy to production the emails will be sent but over time they are stuck in the draft state.

    The workflow instance itself shows a successful completion.

     

    I'm wondering if something is failing in the async service that I'm not aware of.

     

     

    (note that I edited this post to say that they are stuck in the draft state, I had originally incorrectly stated that they were stuck in the pending state)

    • Edited by CarlsbadSGP Thursday, March 3, 2011 4:29 PM
    Wednesday, March 2, 2011 10:32 PM
  • Maybe you'd want to change the title of the thread to reflect the actual behavior. (change draft to pending).
    They are two different states and imply very different scenarios for an email.

    If the workflow were to leave it in the draft state, then that implies that the "Send" action in CRM did not complete.
    Pending state in CRM implies that the Send action in CRM is completed and a client (outlook/router) is yet to pick the emails for processing.

    w.r.t router :
     - How many CRM users/queues are configured in the email router?
     - What is the number of threads configured in router?
     - Are you configuring against Exchange Online?
     - How often is the workflow run?
     
    For more info, you can turn on logging in email router anc check to see that outgoing emails are being processed regularly.
    To do so :

     - In the Service folder of Email router installation, locate the file Microsoft.Crm.Tools.EmailAgent.xml.
     - There is a key for Log Level - <LogLevel></LogLevel> This is by default set to 1. Please set it to 3.
     - Add a key for Log file below this key. <LogFile>C:\Log.txt</LogFile> Mention the desired log file path and name.
     - Restart the Email router service.

    You should be able to see the statement ... checking for outgoing messages to process in.....
    once every 1 - 2 minutes.

    Thursday, March 3, 2011 2:39 AM
  • In that case, my previous reply will not help.

    Could of things that you can check - For any one such email that fails to go through the workflow, please open the record and try clicking on Send manually from the Web app. If it fails to send, you should be able to get an error stating the reason. If it does send, then we may need to investigate further.

    Did you check the attachment extension list?
    Is there anything particular about the emails that dont go through as compared to the ones that do?
    Monday, March 7, 2011 6:28 AM