Sending Email with custom HTML format Body in Orchestration using Dynamic Send Port

Hi,

I need to construct the email body with the values coming in the incoming message.

Below is the sample mail format which I need to send.Please let me know how to implement in Dynamic Sendport with orchestration

March 21st, 2015 8:47am

http://www.codeproject.com/Articles/36210/Sending-an-HTML-formatted-e-mail-message-from-Bi is exactly what you want.

You may choose to create a .Net Component where you store the base HTML message as a template and replace the variables with {0}.... etc. Then create a method where you pass the values and get the formatted HTML back with the values. This you can then assign to the multi-part message of type rawstring.

Regards.

Free Windows Admin Tool Kit Click here and download it now
March 21st, 2015 9:00am

Hi,

You should refer to the article written by Abdul Rafay's on Sending an HTML-Formatted E-Mail Message from BizTalk

Also SMTP Adapter in BTS2006 and HTML formatted messages

Rachit

March 21st, 2015 9:05am

The structure of the email needs to be created by using HTML within C#, while sending emails from BizTalk will not be a tough task.

Just look into the articles shared by others and the below one which gives step by step instructions on how to send emails from BizTalk.

https://www.cleancode.co.nz/blog/1021/sending-emails-biztalk

I would suggest to start with your application development and later contact us in case you are getting any specific error.

Free Windows Admin Tool Kit Click here and download it now
March 21st, 2015 3:12pm

Please advise how to apply HTML template to BizTalk Message in Orchestration
March 21st, 2015 8:25pm

Hi,

You just need to create a new message and initialize it in a message assignment shape like this:

The key parts to notice here is how to just create into a StringBuilder the entire HTML message content, constructed dynamically. Once that's done, assign the resulting string to the RawString object in out EmailBody member of the email and set the part's ContentType Context property to "text/html".

msgbody = new System.Text.StringBuilder();
msgbody.AppendLine("<html><body>");
msgbody.AppendLine("<p>The attached document failed on processing in BizTalk Server.</p>");
msgbody.AppendLine("<p><b>Error details:</b></p><p>");
msgbody.AppendLine("Error Description: <i>" + FailedMessage(ErrorReport.Description) + "</i><br/>");
//msgbody.AppendLine("Message Type: " + FailedMessage(ErrorReport.MessageType) + "<br/>");
msgbody.AppendLine("Error Type: " + FailedMessage(ErrorReport.ErrorType) + "<br/>");
msgbody.AppendLine("Failure Category: " + System.Convert.ToString(FailedMessage(ErrorReport.FailureCategory)) + "<br/>");
msgbody.AppendLine("Failure Code: " + FailedMessage(ErrorReport.FailureCode) + "<br/>");
msgbody.AppendLine("Receive Port Name: " + FailedMessage(ErrorReport.ReceivePortName) + "<br/>");
msgbody.AppendLine("Receive Location: <b>" + FailedMessage(ErrorReport.InboundTransportLocation) + "</b></p>");
msgbody.AppendLine("</body></html>");
EMail.EmailBody = new Microsoft.Samples.BizTalk.XlangCustomFormatters.RawString(msgbody.ToString());
EMail.EmailBody(Microsoft.XLANGs.BaseTypes.ContentType) = "text/html";
EMail.OriginalMessage = FailedMessage;
EMail(SMTP.Subject) = "Failed error message notification";
EMail(SMTP.From) = "someone@somewhere.com";
EMail(SMTP.EmailBodyFileCharset) = "UTF-8";
EMail(SMTP.SMTPHost) = "localhost";
EMail(SMTP.MessagePartsAttachments) = 2;

You can refer to the article SMTP Adapter in BTS2006 and HTML formatted messages

Also refer the discussion around a similar requirement @ Sending Email from BizTalk Orchestration.

Free Windows Admin Tool Kit Click here and download it now
March 22nd, 2015 12:32am

Hey Singam,

The code shared by Rachit should work for you.

But I would suggest you to learn the basics of HTML

HTML Basics

The problem we should be discussing here should be related to BizTalk and not how to create Table, xml etc.

Let us know if you are still facing any issue.

March 22nd, 2015 7:09am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics