Random Musings

May 29, 2009

TDD on DeliverIncomingEmailRequest

Filed under: Dynamics CRM — haditeo @ 7:06 pm
Tags: , ,

There is a scenario where developers would like to convert emails to the related entity let’s say incident.

To process the incoming emails, a plugin needs to be developed that listen to the DeliverIncomingEmail message. Imagine that developers need to setup a vpc which has a valid routable email address and internet connection etc.

Actually in the SDK, we can simulate this by triggering DeliverIncomingEmailRequest CRM service

Developers can use the below code

            DeliverIncomingEmailRequest req = new DeliverIncomingEmailRequest();
            req.From = "from@email.com";
            req.To = "ryan@sample.com";
            req.Subject = "subject" + DateTime.Now.ToLongDateString() + " - " + DateTime.Now.ToLongTimeString();
            req.MessageId = "messageId" + Guid.NewGuid().ToString();
            req.Body = "body" + Guid.NewGuid().ToString();
            req.Cc = "cc@email.com";
            req.Bcc = "bcc@email.com";
            req.ReceivedOn = new CrmDateTime("10/10/2000");
            req.SubmittedBy = "abc";
            req.Importance = "1";


            req.Attachments = new BusinessEntityCollection();
            req.Attachments.EntityName =
            EntityName.activitymimeattachment.ToString();
            
            DeliverIncomingEmailResponse res = (DeliverIncomingEmailResponse)crmService.Execute(req);

Pay attention that one of the recipient must be a valid CRM user with his/her valid email address. In this example, ryan@sample.com is a valid crm user.

This code can be run by using NUnit to make the testing easier.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

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

Blog at WordPress.com.

%d bloggers like this: