question

RaviRanjan-8236 avatar image
0 Votes"
RaviRanjan-8236 asked LeoErlandsson commented

Send Email with Multiple attachments using BizTalk SMTP

Hello,

I need to send multiple attachments (1... n) using BizTalk SMTP adapter. I have created a Multipart message with one body and dynamically adding parts to the multipart message using .Net Helper assembly.

I added one construct shape before the loop and one after inside loop, but my multipart message is always added with latest message part during runtime. It seems my parts are getting overridden with the new one and at last the last part is sent as attachment.

I have referred an old article: https://social.msdn.microsoft.com/Forums/en-US/d3191ca7-c07e-4bb3-84b6-d5416536beef/constructing-multipart-message?forum=biztalkgeneral.

As suggested, I have also created one XLangMessage variable and assigned to the message inside the loop, but I am getting an "Use of unassigned local variable var_XLANG".

Could you all please guide me how to initialize the variable or any new ideas for sending the attachments.

Thanks in advance.

Regards

biztalk-server
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

LeoErlandsson avatar image
0 Votes"
LeoErlandsson answered LeoErlandsson commented

Hi,

We are doing this. Basically, we selected to do the attachment of multiple files in C# Code instead. It's certainly possible to do this in an Orchestration Loop, it's just easier and more performant in Code.

Please see attached screenshot of Orchestration (don't mind the loop that's for other functionality), Message Construct and snipped of C# code.

Br,
Leo
63564-2021-02-03-16-46-58-p-malmo-biztalk2016-ny-dev-v2.png
63565-2021-02-03-16-46-19-p-malmo-biztalk2016-ny-dev-v2.png
63573-2021-02-03-16-45-38-p-malmo-biztalk2016-ny-dev-v2.png



· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Leo,

Thank you so much for your response.

As a workaround, I have followed the same approach. I just wanted to check if this can be done inside the BizTalk orchestration.

Thank you for the information provided by you.

Stay safe and take care.

Regards,
Ravi

0 Votes 0 ·

Hi Leo,
I've just come accross your post and I'm attaching the files via the orchestration. What I'm now encountering is the deletion of the attachments afterwards, can this be done through the orchestration? I know that I have to use Dispose but this is not found using the SMTP adapter in the orchestration. Have you had the same problem?

Thanks in advance for any input! :)

Regards
Omer

0 Votes 0 ·

Hi,

Could you please detail what you mean by"deletion of the attachments"?

Deleting the files on disk?

Br,
Leo

0 Votes 0 ·

Thank you for your prompt reply, yes, I'm sending PDFs as attachments via the orchestration but I'm having problems deleting the files afterwards. These files are dropped on to the BizTalk server and BizTalk sends them as attachments in the emails, once sent, then BizTalk should dispose of these files. What I've done as a temporary solution is to copy the files to a temp folder after the file is sent. I then have a Windows task schedule that deletes all files from the temp folder during off-peak hours. I was just wondering if you had performed a deletion afterwards with your solution.

I've read other posts where they use the Dispose() method to release the attachment but this is done through a helper class that I do not have.

Regards
Omer

0 Votes 0 ·
Show more comments