locked
How to copy an attachment which is an email and digital signed to an Outlook folder? RRS feed

  • Question

  • I have an email with an attachment which itself is a digital signed email in Outlook Inbox. I want to copy the attachnent to any folder such as Inbox. How could I do that using OOM or Advance MAPI, or both?

    The more specific environmen:

    1. the attachment is opened in Inspector by double-clicking the attachment from the hosting email
    2. then try to copy the current email to any outlook folder in my addin.

    Thanks

    jhou

    Thursday, December 9, 2010 3:32 PM

Answers

  • You can still save the attachment as an MSG file uisng OOM, but bring it back to Outlook using Redemption. Something along the lines:

    Attachment.SaveAsFile(...)

    //now use Redemption:

     

    set Session = CreateObject("Redemption.RDOSession")

    Session.MAPIOBJECT = Application.Session.MAPIOBJECT

    set Inbox = Session.GetDefaultFolder(olFolderInbox)

    set NewMsg = Inbox.Items.Add

    NewMsg.Sent = true

    NewMsg.Import(<path to the MSG file>, olMsg)

    NewMsg.Save


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    • Marked as answer by jhou Friday, December 10, 2010 7:09 PM
    Thursday, December 9, 2010 10:24 PM

All replies

  • In OOM, you can save the attachment as an MSG file (Attachment.SaveAsFile), and then bring that mesage back using Namespace.CreateItemFromTemplate.

    <plug>In Redemption. you can access the embedded message uysing RDOAttachment.EmbeddedMsg (will return RDOMail), then just copy that mesage to teh destination folder using RDOMail.CopyTo(SomeFolder)</plug>


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Thursday, December 9, 2010 5:20 PM
  • Thanks for your help.

    I can save the attachment to disk and bring it back using CreateItemFromTemplate without any error. But when I call Save() method on the mailItem, it gave me error message like "Microsoft Office cannot sign or encrypt this message because you have no certificate..", and save() is aborted.

    But for an attachment which is not digital signed, I can save it and bring back without problem.

    In order to use Redemption, I need to have access to the hosting message of the embedded message. In my case, the attachment is already opened in Inspector. Is there a way to find the hosting message from the embedded message, which is currently opened in Inspector.

     

    Thanks

    Jhou

     

    Thursday, December 9, 2010 10:00 PM
  • You can still save the attachment as an MSG file uisng OOM, but bring it back to Outlook using Redemption. Something along the lines:

    Attachment.SaveAsFile(...)

    //now use Redemption:

     

    set Session = CreateObject("Redemption.RDOSession")

    Session.MAPIOBJECT = Application.Session.MAPIOBJECT

    set Inbox = Session.GetDefaultFolder(olFolderInbox)

    set NewMsg = Inbox.Items.Add

    NewMsg.Sent = true

    NewMsg.Import(<path to the MSG file>, olMsg)

    NewMsg.Save


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    • Marked as answer by jhou Friday, December 10, 2010 7:09 PM
    Thursday, December 9, 2010 10:24 PM
  • Thank you very much. It works with Redemption.

    Jhou

    Friday, December 10, 2010 7:15 PM