How to give custom subject and attachment filename to a SMTP adapter in custom component.

Hi,

My requirement is to receive an EDI file, transform, destination is a flat file, email the transformed text file as attachment using SMTP adapter.

I need to give a custom name to the attachment file as per a field value after the mapping. And same for the subject as well.

I am not promoting any fields. What is the context property used in the component and the macros at the SMTP send port?

Best Re

September 13th, 2015 5:05am

I would refer you to https://msdn.microsoft.com/en-us/library/aa560686.aspx for all the properties available on the SMTP Adapter and https://msdn.microsoft.com/en-us/library/ee253440(v=bts.10).aspx on how to set these properties under various scenarios.

Using these two articles you can write a pipeline component to do the same for you.

Regards.

Free Windows Admin Tool Kit Click here and download it now
September 13th, 2015 6:15am

Hi Priya,

You can use the BizTalk Context properties to provide the Dynamic FileName for the attachment and also to provide Subject:

For Subject:

msgSend(SMTP.Subject) = "Your Subject";

For Dynamic FileName:

EmailMessage.attachmentOne(MIME.FileName) = "attach1.xml";

Based on the input you can provide different Subjects and Attachment Name to the output SMTP message.

Message Body Part Attachment SMTP Adapter Dynamic Port Configuration

Rahul

September 13th, 2015 7:39am

// send email via custom business logic component
emailConfig = BL_ConfigurationManager.GetEmailConfiguraionData();
emailSendManager.SendEmailService(emailConfig.EmailSender, emailConfig.EmailRecipients, emailConfig.Subject, InputCustomData_Request.FileName);

Using a business component inside your orchestration could be another approach of handling various mailing services in a more generic way. As outlined in the code lines above in your expression shape you are using 2 typed variables as external objects. One gets the email configuration data, the second implements the kinds of email messaging services. This way all smtp plumbing is hidden away from the orchestration. 

hth

Paul Endras
Endras IT Consulting  |  www.endras.de

If this answers your question and is a helpful post, please click Vote As Helpful, Propose As Answer, and/orMark As Answer.


Free Windows Admin Tool Kit Click here and download it now
September 13th, 2015 8:26am

Hi,

The following blog post will help you in this requirement .

 Sending flat file attachments with an HTML email from BizTalk

 Sending a mail with an attachment & body text

Sending original CSV file, name and extension using SMTP Adapter

Thanks
Abhishek

September 13th, 2015 5:15pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics