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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Set Email Id on To field in Email Activity in MS CRM 2013

(0) ShareShare
ReportReport
Posted on by 1,616

Hi All,

I successfully created an email activity, but i'm not able to set an email id("sample@gmail.com") on "To" field.

Could anyone help me to resolve this?

Thanks in advance.

*This post is locked for comments

I have the same question (0)
  • Royal King Profile Picture
    27,686 on at

    To field is a type of party list so you have to create party list and assign that object to "to" field in a email record

    In javascrpt  :

    var partlistData = new Array();

      partlistData[0] = new Object();

      partlistData[0].id = <guid>;

      partlistData[0].name = "Joe CRM";

      partlistData[0].entityType = 2;

      Xrm.Page.getAttribute("to").setValue(partlistData);

    c# :

    ActivityParty toParty = new ActivityParty

               {

                   PartyId = new EntityReference(Contact.EntityLogicalName, _contactId)

               };

               Console.WriteLine("Created activity parties.");

               // Create an e-mail message.

               Email email = new Email

               {

                   To = new ActivityParty[] { toParty },

                   From = new ActivityParty[] { fromParty },

                   Subject = "SDK Sample e-mail",

                   Description = "SDK Sample for SendEmail Message.",

                   DirectionCode = true

               };

  • Sathiamoorthy S Profile Picture
    1,616 on at

    Chitra,

    Thanks for your reply.

    I am able to set the record(s) in "TO" field which are already exists in crm system. but i need to set mailid(sample@gmail.com) directly in "TO" field using javascript REST.

    Thanks,

  • Verified answer
    Royal King Profile Picture
    27,686 on at

    There is no way you can set email address in the "to" field using script. Though you can do this using c#

    ActivityParty toList = new ActivityParty();

    toList.AddressUsed = abc@xyz.com;

  • Verified answer
    Royal King Profile Picture
    27,686 on at

    Hello Sathiamoorthy,

    I found something this morning related  to your query that is interesting to know

    find below the sample i found to set emailaddress in the to field.

    I have tested this in my environment and it works .

    function setUnresolvedRecipient() {

       var unresolvedemail = "test@testing.com"

      // if (unresolvedValue != null) {

           var obj = new Object(); //create the unresolved object

           obj.name = unresolvedemail;

           obj.category = 3;

           obj.data = unresolvedemail;

           obj.type = "9206";

           var toField = Xrm.Page.getAttribute("to");

           var toValue = toField.getValue();

           if (toValue != null) {

               toValue.push(obj); //if there are already other values, add to it

               toField.setValue(toValue);

           }

           else {

               toField.setValue([obj]); //if 'to' field is null, just override it

           }

          // unresolvedField.setValue(null); //wipe the field after adding it to the 'to' list

      // }

    }

  • Verified answer
    Sathiamoorthy S Profile Picture
    1,616 on at

    Thanks Chitra.

    It works for me too.

  • Sathiamoorthy S Profile Picture
    1,616 on at

    Hi Chitra,

    Now i'm able to set mailid in "to" field of email activity form. But the mailid is showing in red color. Is this will make any issue in sending mail?

    Thanks,

  • Ramakanta Profile Picture
    2,715 on at

    Hi,

         Are you Facing  any problem  in sending email after setting the To Field  Through JS.

    Regards,

    Ramakanta

  • Community Member Profile Picture
    on at

    Hi All,

    In Dynamic 365 v9, unified interface the code does not working.

     and what is type and category  onto the object you have assigned.

    Is i am giving wrong category and type?

    giving me error

    toFieldError.jpg

    Thanks in Advance

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans