Announcements
No record found.
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
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
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,
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;
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
// }
Thanks Chitra.
It works for me too.
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?
Hi,
Are you Facing any problem in sending email after setting the To Field Through JS.
Regards,
Ramakanta
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
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.
Congratulations to our 2026 Super Stars!
We are thrilled to have these Champions in our Community!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
ScottDurow 2
GJones 1