web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Unanswered

Email Tracking Token retrieving always CRM:0000001 for manually send mail by PlugIn assembly

(0) ShareShare
ReportReport
Posted on by 619

Hi All,

I am using Dynamics CRM 2016 - On-Premise for development. I am doing customization for email to case creation and after create case, sending mail to customer about case details. For this, I am not using Queue management to create case. Because before create case, I have to check whether incoming mail address is in existing account or if contact matching with the sending mail address, retrieving contact parent customer as case customer. If nothing is matching, some default customer has to be set in case customer. Hope this validation is not exist in Queue to case creation. So, I am doing it manually.

I am sending mail to customer manually after create case by using plug in assembly. Whenever I am sending mail manually the tracking token is same for all the mail as CRM:0000001.  Means, if I am sending mail through workflow it is taking the latest tracking token for eg., CRM:0195101. So when i am getting reply from customer, i can track with this tracking token. But for manually through code, it is taking all the time CRM:0000001. I am using below code for sending mail

SendEmailRequest sendEmailRequest = new SendEmailRequest();
sendEmailRequest.EmailId = emailId;
sendEmailRequest.IssueSend = true;
sendEmailRequest.TrackingToken = "";
SendEmailResponse sendEmailResponse = (SendEmailResponse)service.Execute(sendEmailRequest);

In this, i tried with GetTrackingTokenEmailRequest method also. But same issue.

Kindly help to fix the problem

Thanks,

Saratha

I have the same question (0)
  • Pankaj Gogoi Profile Picture
    3,177 on at

    Hi Saratha,

    Here is what the document says.

    "When this API generates a tracking token, the API is designed to return an auto incrementing tracking token when the caller is a regular user. The API returns a static token "1" formatted in the configured organization-level tracking token format when the caller is a special system user: SYSTEM, INTEGRATION USER"

    docs.microsoft.com/.../microsoft.crm.sdk.messages.sendemailrequest.trackingtoken

    Are you calling this as a regular user?

    Hope this helps

    Best Regards

    PG

  • Saratha Profile Picture
    619 on at

    Hi Pankaj,

    Thank you for your response. Only regular user will get the incremented Tracking Token?  Is it possible, admin user can get the incremented tracking token. Or apart from this, any other way to get the latest token.

    Thanks,

    Saratha

  • Pankaj Gogoi Profile Picture
    3,177 on at

    Hi Saratha,

    How are you invoking the workflow, is it within the user context or as the owner of the workflow. I suggest using the user context.

    Best Regards

    PG

  • Saratha Profile Picture
    619 on at

    Hi Pankaj,

    I am not using workflow for send mail. When queue item creating, I am triggering plugIn. I am taking the object id of queue item if it is mail type. I am creating the case through code only. From mail, I am taking the sender mail id (From address used) and after create case, sending mail to customer with case details. "SendMailRequest" using for send mail.

    Thanks,

    Saratha

  • Pankaj Gogoi Profile Picture
    3,177 on at

    Hi Saratha,

    Can you use a console application to execute the code and see if the token is incremented.

    Entity fromActivityParty = new Entity("activityparty");
    Entity toActivityParty = new Entity("activityparty");
    
    Guid contactId = (Guid)a.Attributes["contactid"];
    
    fromActivityParty["partyid"] = new EntityReference("systemuser", new Guid("1568d957-50ac-473a-9883-163456849c0c"));
    toActivityParty["partyid"] = new EntityReference("contact", contactId);
    
    Entity email = new Entity("email");
    email["from"] = new Entity[] { fromActivityParty };
    email["to"] = new Entity[] { toActivityParty };
    email["regardingobjectid"] = new EntityReference("contact", contactId);
    email["subject"] = "This is the subject";
    email["description"] = "This is the description.";
    email["directioncode"] = true;
    Guid emailId = _crmServiceClient.Create(email);
    
    // Use the SendEmail message to send an e-mail message.
    SendEmailRequest sendEmailRequest = new SendEmailRequest
    {
        EmailId = emailId,
        TrackingToken = "",
        IssueSend = true
    };
    
    SendEmailResponse sendEmailresp = (SendEmailResponse)_crmServiceClient.Execute(sendEmailRequest);
    Console.WriteLine("Email sent");
    Console.ReadLine();

    Best Regards

    PG

  • Saratha Profile Picture
    619 on at

    Hi Pankaj,

    Thank you for your follow up. In the plugIn code, I have done the same thing as I mentioned below. But it's not working. As you told, I am not a non interactive user. Other than non interactive user, how to get the incremented tracking token.

    SendEmailRequest sendEmailRequest = new SendEmailRequest();

    sendEmailRequest.EmailId = emailId;

    sendEmailRequest.IssueSend = true;

    sendEmailRequest.TrackingToken = "";

    SendEmailResponse sendEmailResponse = (SendEmailResponse)service.Execute(sendEmailRequest);

    Thanks,

    Saratha

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 73 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 42 Most Valuable Professional

#3
Scott Jackson UK Profile Picture

Scott Jackson UK 22

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans