BTS: Sending E-Mail in HTML or Text Format from BizTalk 2004

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.

The solution consists of the following:

  1. A library class that contains the RawString and Part classes to make it easy to set the type of the message.
  2. A BTS project that contain a pipeline to use for sending the e-mail.
  3. 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.



About the Author

Moustafa Refaat

Over 15 years of experience developing software solutions, leading the Architecture, Design, and Refactoring of many big projects. At Siemens, led the architecture, design and implementation of the Real time server and Newscaster for the HiPath Pro (A CRM management system). At Bell/ Sympatico MSN web modernization project led the BizTalk development team, responsible for the solution architecture, developing the core framework, mentoring and supporting the team members on the Solution and BizTalk issues. Holds IEEE/CSDP, MCSD(6.0, and .Net) and Oracle certifications. Acts as a referee for the IEEE Software magazine. With International and US experience in financial services automation.

Downloads

Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • Live Event Date: October 29, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT It's well understood how critical version control is for code. However, its importance to DevOps isn't always recognized. The 2014 DevOps Survey of Practice shows that one of the key predictors of DevOps success is putting all production environment artifacts into version control. In this eSeminar, Gene Kim will discuss these survey findings and will share woeful tales of artifact management gone wrong! Gene will also share examples of how …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds