You really ask three different questions here.
- How to send an HTML email address to BizTalk.
- How to add email attachments to BizTalk.
- How to dynamically read files in a BizTalk process.
I turn to each of them below - the simplest solution to problem 2 actually avoids the problem with problem 3.
Hope this helps you find the right way to solve this problem. Unfortunately, it is so wide that I cannot give a single โthis is how you do it,โ but if you click โdriftwoodโ, go back and send more questions.
How to send an HTML email address to BizTalk
There are two methods that I know to achieve this.
One of them is to use the RawString class and assign it directly to your email body. This is well demonstrated in this Tomas Restropo blog post .
The second way is to use the XSLT Transform Pipeline component, described in detail here on MSDN . This works by letting you specify XSLT templates that transform your body of a regular test message into an HTML body.
I have used both approaches in the past. Each has its own strengths and weaknesses. One of the nice features of the template method is that it is slightly configurable in production mode (but only a little if you have developed another option well).
How to add email attachments in BizTalk
Again, there are two main ways to achieve this in BizTalk.
The first method is to use the SMTP.Attachments context SMTP.Attachments . In the message assignment expression form inside your orchestration, you have the code as shown below:
MessageOut(SMTP.Attachments) = "C:\\Attachments\MyFile.pdf|C:\\Attachments\AnotherFile.pdf";
You simply add a list of files where file paths are limited by channel.
This can be a good help for your requirement - this is the easiest way to dynamically add email attachments and avoids the need to actually upload files to BizTalk.
In addition, the above form of expression is just code, so you can make the above dynamic as you need.
Another method is to send a multi-page message from BizTalk. Depending on the context settings, you can send all parts of messages as attachments or use the first part as a message body.
Creating a multi-page message is a bit tied up, so I wonโt go into it - usually you will need a helper class that adds parts to your message.
Context properties (specified in the message destination form):
MessageOut(SMTP.MessagePartsAttachments) = n // Where n can be one of three values 0 (same as not set) - Do not attach any biztalk message parts. This is a default setting. 1 - Attach only biztalk body part 2 - Attach all parts
How to dynamically read files in a BizTalk process
This is again very important, so I will not go into details. There are other issues that relate to this issue.
In fact, if you use multi-page messages, you will need to somehow get each part of the message in BizTalk.
You have several options:
- A static list of files that you get each one going to the destination is not so good for you, because it sounds like PDF files can change.
- A master orchestration that reads your control file and then โorganizesโ the behavior of the child orchestrations.
- The code-based solution is the C # class, which takes your list of files and returns them to BizTalk as messages (or even adds them as parts of the message to another message).
- Some kind of special solution for the adapter - perhaps a huge overflow for what you need.