WEBINAR: On-demand webcast
How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >
BTS: Sending E-Mail in HTML or Text Format from BizTalk 2004
I needed to send an e-mail directly from BTS 2004; this was part of an error handling mechanism. However, going through a schema was too much; all I needed is to be able to assemble a string and send it through a SMTP port. As you know, e-mail messages always contain message text, generally in a text or HTML format, and may contain one or more attachments as well. I needed to send the e-mail in HTML format. After going through the SDK and the documentation, I could not find an easy, well-documented solution for this, so I had to assemble the solution attached with this submission.
Sending a message of type System.String will not work because the string gets formatted as an XML document in the message, which is not my desired solution. To send text in an e-mail message, you must use a special type of string, one that has special serialization with the XML; in other words, implements an IFormatter interface. In the attached solution, you will find the "RawString" class that implements IFormatter. You also need to implement a pipeline containing the MIME/SMIME Encoder pipeline component. Now, you have to tell the MIME/SMIME pipeline component that it is dealing with a body with content type of text/HTML through the Microsoft.XLANGs.BaseTypes.XLANGPart.SetPartProperty method.
- A library class that contains the RawString and Part classes to make it easy to set the type of the message.
- A BTS project that contain a pipeline to use for sending the e-mail.
- A simple orchestration that accepts a simple file schema and just sends the e-mail. The input file in this example is empty. It is just used to fire the orchestration.
I hope this will make your development project easier. Let me know what you think. You can check my blog at http://moustafarefaat.blogspot.com.