Quantcast
Channel: Yet Another MS Dynamics CRM blog
Viewing all articles
Browse latest Browse all 25

Creating Email through Plugin / SDK in CRM 4 - line breaks don't work

$
0
0

You may have noticed when you create email using a sample code like below in a plugin or for that matter any other SDK based assembley for MS CRM. Your line breaks : \n or \r or System.Environment.NewLine will not work.


          email Email = new email();   
                     Email.to = new activityparty[] { toParty };
                     Email.from = new activityparty[] { fromParty };
                     Email.regardingobjectid = regardingObject;
                     Email.subject = "Hello!!";
                     Email.description = "Dear, line 1" +         
                     System.Environment.NewLine+  
                      "my message for your - line 2";
                     Email.directioncode = new CrmBoolean();
                     Email.directioncode.Value = true;
                     
                     Guid _emailId = _service.Create(Email);
                     
                     SendEmailRequest sendEmailRequest = new SendEmailRequest();
                     sendEmailRequest.EmailId = _emailId;
                     sendEmailRequest.TrackingToken = "";
                     sendEmailRequest.IssueSend = true;


I went into the business entity object that service will return when you query existing Emails in MSCRM, the .description field will have value like HTML rich text code :

.description = " < FONT size=2 face= \"Tahoma, Verdana, Arial \ " >your text < br / >"


So the key is to add "< br / >" as line feed instead of the common dot net and javascript carriage returns and you will be able to format your emails as you want from inside SDK plugins and more.


Viewing all articles
Browse latest Browse all 25

Trending Articles