SMTP Adapter and Binary attachments

Home Page › Forums › BizTalk 2004 – BizTalk 2010 › SMTP Adapter and Binary attachments

Viewing 1 reply thread
  • Author
    Posts
    • #22717

      I know this has been long documented, but I can not find anything that tells me how to do what I am attempting accross all my searches, so I am throwing it out there in the hope of some help…..

      I am writing a generic EMailer service in biztalk that will handle emails for all biztalk apps that my current client writes.

      The EMailer consists of a schema that defines an email and associated fields.  I have got it successfully sending html\text emails and forwarding text\html\xml attachments, however I would like it to also send binary attachments. 

      The schema has a node called <BinaryData encoding=”” filename=””></BinaryData>. 

      The data in this node is a MIME encoded string.  I want to use this string to create a new messagepart  that will become an attachment to an SMTP mesage.  When the message is sent out I want the attachment to be the intended file. 

      Could anyone suggest how I should go about this (not using SMTP.Attachments) but using addpart or some equivalent….

      Thanks

      Dinoo

    • #22753

      Hooray, I have solved the problem by piecing together a couple of blogs on binary attachments and mime encoding. 

      Turns out that the way to do this is to convert the base64 data back to a byte array, create a editable  memory stream from this byte array and add this using the message addpart() method.  The following code that does this….

      public static void AddMIMEPart(XLANGMessage msg, String partName, String partFileName, string encoding, String partData)
      { 
        switch (encoding.ToUpper())
        { 

          case “BASE64” : 
           
      StreamFromBase64 ms = new StreamFromBase64 (partData);
            msg.AddPart(ms.CreateStream(), partName);
            msg[partName].SetPartProperty(
      typeof(MIME.FileName), partFileName); 
           
      break; 
          default: 
            throw new Exception(“Stream is not in a recognized encoding type”
      );

Viewing 1 reply thread
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.