Programmatically closing all Open Activities (e.g. Email) in CRM 3.0

First we need to retrieve all”Open” activities (e.g email) . We can use Query expression or FetchXML . I am just skipping that step. Once we are done with query , here is the piece of code, which will close the all Open emails.
BusinessEntityCollection ret = service.RetrieveMultiple(query);

for (int i = 0; i < ret.BusinessEntities.Length; i++)
{

email see = (email)ret.BusinessEntities[i];

SetStateEmailRequest closing = new SetStateEmailRequest();
closing.EmailState = EmailState.Completed;
closing.EmailStatus = -1;

closing.EntityId = see.activityid.Value;
SetStateEmailResponse statset = (SetStateEmailResponse)service.Execute(closing);

}

Advertisements

0 Responses to “Programmatically closing all Open Activities (e.g. Email) in CRM 3.0”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s





%d bloggers like this: