I understand that my problem is very old and looks trivial, but nevertheless…I’m pretty new in creating custom components, I’ve looked through similar questions here and stuck with one thing.
So, I need to send out email through SMTP adapter with the attached flat file (single, result of previous processing/mapping) with certain name, different from “body”. For this I’ve made a simple component to set this name, it’s code as simple as it’s possible: it contains only mandatory methods and this:
public IBaseMessage Execute(IPipelineContext pc, IBaseMessage inmsg)
{
inmsg.BodyPart.PartProperties.Write(TargetProperty, TargetNamespace, OutgoingAttachedFileName);
return inmsg;
}
Where TargetProperty = “FileName”, TargetNamespace = “http://schemas.microsoft.com/BizTalk/2003/mime-properties” and OutgoingAttachedFileName comes from the component property (but when testing I tried also to hardcode it as OutgoingAttachedFileName = “somename.ext”, it did not help).
I’ve added this component to the outgoing pipeline (so my pipeline contains FlatFileAssembler and this one) and the result confused me. It impacts only the extension of the attached file. If this component is not present, the attached file has the name “body”. But, if it is present, the attached file has the name “body.ext”, where .ext is the extension of the filename which I specify in the component property and which goes to OutgoingAttachedFileName. E.g. if I specify it as “ImportResult.txt”, the attached file has the name “body.txt”, if I set it to “ParseResult.csv”, the attached file is “body.csv”, etc.
This completely confused me. Since I’m new to this, I would understand if it would not work at all, but partially working?
Can anyone advise, what am I doing wrong? I would appreciate any help.
Environment is BT 2020, SMTP adapter settings are pre-defined text and “Attach only body part”.
Thanks in advance.