Search code examples
biztalkbiztalk-2016

BizTalk Orch/SMTP - Microsoft.XLANGs.BaseType.Content must be a message property of


This is related to my question from 2017: How Set Attachment Name to Show Properly in Outlook

This time, I have an orchestration with the following in a construct shape:

 attachmentName = System.IO.Path.GetFileName(
          msg_Ledger6002_File_XmlDoc 
                 (FILE.ReceivedFileName));

msg_Email.BodyPart = new ABC.Ledger6002.Component.RawString("See attached email."); 
msg_Email.AttachmentPart = msg_Ledger6002_File_XmlDoc;
// attachmentName is set earlier in orch so we could write it to EventLog for debugging 
msg_Email.AttachmentPart(MIME.FileName) =  attachmentName; 
//msg_Email.AttachmentPart(MIME.ContentDescription) = "body";
//msg_Email.AttachmentPart(MIME.ContentTransferEncoding) = "base64"; 

// These are working
msg_Email(SMTP.Subject) = "Ledger6002 File";
msg_Email(SMTP.SMTPTo) = msg_Config_Email.smtpToEmail;
msg_Email(SMTP.From) = msg_Config_Email.smtpFromEmail;
msg_Email(SMTP.SMTPAuthenticate) = 0;   // do not authenticate to SMTP server 

// trying these two new parms below 
msg_Email(SMTP.EmailBodyTextCharset) = "UTF-8";
msg_Email(Microsoft.XLANGs.BaseTypes.ContentType) = "text/plain"; 

The last line above gives me an expression shape not valid, and when I mouse over it it says identifies the error as:

Microsoft.XLANGs.BaseType.Content must be a message property of msg_email.

Before I added the two lines under the comment "trying these two new parms below", I am getting an email with the desired attachment. The problem is that it is just called "body" and when I do "save as" from Outlook, it wants to call it "body" instead of the name of the file I dropped.

I'm using a "specify later" statically configured SendPort with PassThru for the Pipeline. I have tried a pipeline with MimeEncoder, but that caused the attachment to appear in the body. I would like to move to a dynamic pipeline, but so far I've got the static one working except for the name assigned to the file attachment.


Solution

  • To fix the error: "Microsoft.XLANGs.BaseType.Content must be a message property of msg_email.", I just needed to include the part name (the message is associated with a multipart message type, and I didn't include the partname):

    Wrong:

    msg_Email(Microsoft.XLANGs.BaseTypes.ContentType) = "text/plain"; 
    

    Right:

    msg_Email.BodyPart (Microsoft.XLANGs.BaseTypes.ContentType) = "text/plain";
    

    I'm still working on getting the email with attachment to come out correctly, but so far this post https://social.msdn.microsoft.com/Forums/en-US/988b0d91-1e5a-4f73-b30d-417d6ea9fa75/attachment-name-in-outlook-is-ok-see-on-exchange-always-named-body?forum=biztalkgeneral seems to be the best explanation.