Microsoft Developer Network > Forums Home > BizTalk Server Forums > BizTalk Server General > Forward the original email as attachment
Ask a questionAsk a question
 

AnswerForward the original email as attachment

  • Monday, July 13, 2009 12:58 PMTuanL Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    I would like to send the orginal email as attachment with use a dynamic send port (SMTP). Is this possible?

    Thanks,
    Tuan

Answers

  • Monday, July 13, 2009 9:26 PMeliasenMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi

    No easily, no.

    Mostly, when peopole want to attach an email to another email, they are talking about attaching the .msg file, which is really outlook/exchange specific.

    When you use BizTalks pop3 adapter, you get some MIME text, which the MIME decoder pipeline component will convert into a multipart message for you. If you want to attach this to a new mesage, I think you need to program your own pipeline component which will take all the message parts and convert them nto the .msg format you want and let that be the second message aprt of a new IBaseMessage, where the first part (the bodypart) is whatever you want in the email other than the attached mail.

    eliasen, representing himself and not the company he works for.
    Three times MVP and three times MCTS in BizTalk.
    Blog: http://blog.eliasen.dk
    • Marked As Answer byTuanL Tuesday, July 14, 2009 9:27 AM
    •  
  • Tuesday, July 14, 2009 6:44 AMThiago AlmeidaMVP, AnswererUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    You can try changing the "Apply MIME Decoding" property of the POP3 adapter to false, and use a passthrough receive pipeline so you get the original message into BizTalk. You can then attach the message to an outgoing email, giving the attachment a .eml extension.
    If you need to inspect the original email before attaching it you get the original message as mentioned above into an orchestration and call a pipeline with the MIME/SMIME pipeline component from the orchestration to extract the message part you're interested in.


    Thiago Almeida - http://connectedthoughts.wordpress.com
    • Marked As Answer byTuanL Tuesday, July 14, 2009 8:02 AM
    •  

All Replies

  • Monday, July 13, 2009 9:26 PMeliasenMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi

    No easily, no.

    Mostly, when peopole want to attach an email to another email, they are talking about attaching the .msg file, which is really outlook/exchange specific.

    When you use BizTalks pop3 adapter, you get some MIME text, which the MIME decoder pipeline component will convert into a multipart message for you. If you want to attach this to a new mesage, I think you need to program your own pipeline component which will take all the message parts and convert them nto the .msg format you want and let that be the second message aprt of a new IBaseMessage, where the first part (the bodypart) is whatever you want in the email other than the attached mail.

    eliasen, representing himself and not the company he works for.
    Three times MVP and three times MCTS in BizTalk.
    Blog: http://blog.eliasen.dk
    • Marked As Answer byTuanL Tuesday, July 14, 2009 9:27 AM
    •  
  • Monday, July 13, 2009 9:40 PMThiago AlmeidaMVP, AnswererUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    How are you receiving the original email into BizTalk? Via the POP3 adapter or has the email been saved to a file before BizTalk receives it?


    Thiago Almeida - http://connectedthoughts.wordpress.com
  • Tuesday, July 14, 2009 5:15 AMTuanL Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    BizTalk receives the original email via POP3. I want to add the original email as attachment, because I want to generate a workflow instruction in the new email and the receiver will need to have the original email.

    Tuan
  • Tuesday, July 14, 2009 6:44 AMThiago AlmeidaMVP, AnswererUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    You can try changing the "Apply MIME Decoding" property of the POP3 adapter to false, and use a passthrough receive pipeline so you get the original message into BizTalk. You can then attach the message to an outgoing email, giving the attachment a .eml extension.
    If you need to inspect the original email before attaching it you get the original message as mentioned above into an orchestration and call a pipeline with the MIME/SMIME pipeline component from the orchestration to extract the message part you're interested in.


    Thiago Almeida - http://connectedthoughts.wordpress.com
    • Marked As Answer byTuanL Tuesday, July 14, 2009 8:02 AM
    •  
  • Tuesday, July 14, 2009 8:21 AMTuanL Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Yes, it works.

    There are only 2 issues that I need to solve:
    1. I need to attach it as an Outlook message (not Outlook Express)
    2. I loss all POP3 context properties

    But this is something that I start with. Many thanks for your help.

    Tuan
  • Tuesday, July 14, 2009 8:23 AMeliasenMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi

    Getting the oulook message instead of outlook express (ie. the .msg formet) requires programming, as I understand it - like a custom pipeline component like I described earlier.

    What do mean by loosing the pop3 context properties? Are you talking about the .eml file not having the correct from, to, subject, etc. fields? Or where do you need the properties?

    eliasen, representing himself and not the company he works for.
    Three times MVP and three times MCTS in BizTalk.
    Blog: http://blog.eliasen.dk
  • Tuesday, July 14, 2009 8:34 AMeliasenMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi

    Untested... but if you make a pipeline component that sets the MIME.FileName property on the message part that contains the message received by pop3 (probably, you only have one message part) to be "something.msg" - will it work? I mean.. setting the filename to a .msg will cause the file to be opened in outlook - just not sure if outlook will complain about this.

    If you don't want to write a pipeline component just yet, try sending your message through an orchestration - and set the property and output the message.

    eliasen, representing himself and not the company he works for.
    Three times MVP and three times MCTS in BizTalk.
    Blog: http://blog.eliasen.dk
  • Tuesday, July 14, 2009 9:11 AMTuanL Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Eliasen,

    If I change "Apply MIME Decoding" property of the POP3 adapter to false, then I cannot access POP3 context properties anymore, like POP3.From, POP3.Subject e.g.

    I have tried to change the file extension from .EML to .MSG, but Outlook fails to open it. I have compared the content of Outlook MSG (by using Save as...) and the content of Outlook Express EML (BizTalk sends). They look completely difference.

    I think that only your suggestion (Custom pipeline component) will work. (I will appreciate if you know where I can get some codes to start with.)

    Thanks for your response,
    Tuan


  • Tuesday, July 14, 2009 9:13 AMeliasenMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi

    Do you need those properties?

    All I can help you with for code is the BizTalk pipeline componet specifics. As to how to create a .msg file, I can't help you - in that case you are probably better off finding a outlook forum and seek help there.

    eliasen, representing himself and not the company he works for.
    Three times MVP and three times MCTS in BizTalk.
    Blog: http://blog.eliasen.dk
  • Tuesday, July 14, 2009 9:27 AMTuanL Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Yes, I do need POP3.From and POP3.Subject. Because on the info in POP3.Subject I decide which branch it has to be executed.

    I will search in Outlook for the conversion to .msg.

    Thanks,
    Tuan
  • Tuesday, July 14, 2009 9:57 AMeliasenMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi

    Well, this is "bad" news :-) If you need those properties, then you need some extra functionality that will find out those values for you. Right now, what I can think of is a pipeline component that you can use in the pipeline before all other components that will parse the incoming message and promote those two values yourself.

    eliasen, representing himself and not the company he works for.
    Three times MVP and three times MCTS in BizTalk.
    Blog: http://blog.eliasen.dk
  • Tuesday, July 14, 2009 11:03 AMThiago AlmeidaMVP, AnswererUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Sorry I can't test this at the moment, but I think there's a hidden context property called "CopyMailHeadersToContext" of the pop3 adapter namespace http://schemas.microsoft.com/BizTalk/2003/pop3-properties that if you write this property with a value of 3 to the message context then put the email through the MIME/SMIME decoder component it will write the mail headers to the context like the POP3 adapter would.
    Thiago Almeida - http://connectedthoughts.wordpress.com
  • Tuesday, July 14, 2009 11:16 AMeliasenMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi Thiago

    Sounds interesting (And cute with the disable mime decoding to get the .eml - I didn't know that...)

    On My BizTalk 2009 here I only have these in the POP3 namespace:
    CC
    Date
    DispositionNotificationTo
    From
    Headers
    ReplyTo
    Subject
    To

    So could it be in another namespace, perhaps? I googlet your "CopyMailHeadersToContext" but that came up empty.


    eliasen, representing himself and not the company he works for.
    Three times MVP and three times MCTS in BizTalk.
    Blog: http://blog.eliasen.dk
  • Tuesday, July 14, 2009 7:29 PMThiago AlmeidaMVP, AnswererUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    it seems to be an undocumented property shared between the POP3 adapter and the MIME decoder COM dll (BTSMIMEComps.dll). I can't test it at the moment because I only have a biztalk 2009 on windows 2008 machine without a mail server to play with...
    Thiago Almeida - http://connectedthoughts.wordpress.com