'C#: Save selected outlook message as eml file
I created an add-on for outlook using c#. It is proposed to connect to external Document Management System(DMS) and upload documents/emails into it. And now I want to save/send selected message from outlook window into DMS by clicking a button from plugin (see picture above). Is there any proper way to do it diractly? If no, please provide the methods to do it in alternative way.
below is an example how my button and message looks like
Solution 1:[1]
Outlook Object Model does not support saving messages in the EML (MIME) format.
You can either
1 Create MIME file explicitly in your code one property at a time. You can also use existing MIME converters (I used Lumisoft in the past) - but they won't convert Outlook messages in a single call; you will need to explicitly build all the headers and MIME parts.
2 Use IConverterSession object (C++ or Delphi only) - this is the same MIME converter used by Outlook. You can play with it in OutlookSpy (I am its author - click IConverterSession button).
3 Use Redemption (I am also its author) and its RDOMail.SaveAs
or SafeMailItem.SaveAs
methods - it can save in the MIME format (olRfc822) along with a dozen or so other formats. It uses IConverterSession object when it is available (Outlook 2003 and up) or its own converter for an older version of Outlook or when used against the Exchange version of MAPI. The following script will save the currently selected message as an EML file.
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set rItem = Session.GetMessageFromID(Application.ActiveExplorer.Selection(1).EntryID)
rItem.SaveAs "c:\temp\test.eml", 1024
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |