
Hi All,
I need one help!
I have the code below to create an email activity in CRM 2011 but i dont know how to send it immediately as it is created.
ClientCredentials Credentials = new ClientCredentials(); Credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials; //This URL needs to be updated to match the servername and Organization for the environment. Uri OrganizationUri = new Uri("http://ftssqa/FastTrack/XRMServices/2011/Organization.svc"); Uri HomeRealmUri = null; //OrganizationServiceProxy serviceProxy; using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, null)) { IOrganizationService service = (IOrganizationService)serviceProxy; //Instantiate the contact object and populate the attributes. Entity emailCreate = new Entity("email"); emailCreate["subject"] = "test subject"; emailCreate["description"] = " test description"; Entity ap = new Entity(); Entity ap2 = new Entity(); //You can comment out the line for addressused and use the partid instead to use an entity reference for an activity party //I just wanted to show how you can specify an email address for an email as an activity party without an entity to go with it. ap = new Entity("activityparty"); //ap["partyid"] = new EntityReference("systemuser", new Guid("CE08EE7F-4F36-E111-B6F6-0050569838D6")); ap["addressused"] = "dhaval.panchal@fasttrackteam.com"; Entity[] aryTo = { ap }; emailCreate["to"] = aryTo; ap2 = new Entity("activityparty"); ap2["partyid"] = new EntityReference("systemuser", new Guid("5ACD43CE-4C09-E211-8627-E06995886FCB")); Entity[] aryFrom = { ap2 }; emailCreate["from"] = aryFrom; // This is how you assign an a reguarding object emailCreate["regardingobjectid"] = new EntityReference("account", new Guid("4AFAE8DB-FB11-E211-8655-E06995886FCB")); Guid newContactId = service.Create(emailCreate); //This code will clear the textboxes after the contact is created. }
Any suggestion? Also i need to get all email activities send/receive times with subject from CRM.
Please share your idea and would be appreciated!
Thank You in Advance.
Dhaval Panchal
*This post is locked for comments
I have the same question (0)I would probably have the code change a field in CRM that triggers a workflow to create the activities and send them out instead of creating the whole solution via code.
For example, you add a two-options field in CRM called "Run Workflow", when the code runs it sets the field to Yes, the workflow runs and it does it's thing setting the field back to No in the process. Repeat this as needed.
Does that make sense?