In BT2006R2 I have an orchestration which receives an XML with email properties like: to, cc, subject, filelocation for htmlbody, 1..n filelocations with pdf files
I want the orchestration to send 1 email with the SMTP adapter with the HTML emailbody and 1..n pdf files as attachments.
How can this be done ?
You are really asking three seperate questions here.
I address each below - the most simple solution to issue 2 actually avoids having to deal with issue 3.
Hopefully this will get you on the right track for solving this. Sadly, it is so broad that I can't give a single "this is how you do it answer", but if you hit snags, come back and post more questions.
How to send an HTML email in BizTalk
There are two methods that I know of to achieve this.
One is to use the RawString class and assign this directly to your email body. It is well demonstrated in this blog post by Tomas Restropo.
The second method is to use the XSLT Transform Pipeline component detailed here on MSDN. This works by allowing you to specify XSLT templates that will transform your plain test message body into an HTML body.
I've used both approaches in the past. Each has its strengths and weaknesses. One nice feature of the template method is that it is slightly more runtime configurable (but only slightly if you design the other way well).
How to add attachments to email in BizTalk
Again, there are two main methods of achieving this in BizTalk.
The first method is to use the SMTP.Attachments
context property. In a message assignment expression shape within you orchestration you have code like below:
MessageOut(SMTP.Attachments) =
"C:\\Attachments\MyFile.pdf|C:\\Attachments\AnotherFile.pdf";
You simply add a list of files, where the file paths are pipe delimited.
This could be a good match for your requirement - it is the easiest way of dynamically adding attachments to an email, and avoids needing to actually load the files into BizTalk.
Also, the above expression shape is simply code so you can make the above as dynamic as you need.
The other method is to send a multipart message from BizTalk. Depending on context settings you can send all message parts as attachments, or use the first part as the message body.
Creating a multipart message is a little involved so I won't go into it - generally you will need a helper class that adds parts to your message.
The context properties (set in a message assignment shape) are:
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 in files to a BizTalk process
This again is quite involved so I won't go into great detail. There are other SO questions that address this.
Essentially, if you are using multipart messages, you will need to get each message part into BizTalk somehow.
You have a few options:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With