HOWTO Programmatically save an Outlook email to file.

A

ATS

HOWTO Programmatically save an Outlook email to file.

Please help,

My company is trying to make Outlook save emails to file programmatically.
The idea is to have an external EXE running, that "tells" Outlook to save a
currently open email to file, or to a set of highlighted emails to file. The
most ideal soltuion would be for this communication to occur seemlessly, with
no distracting GUI operation occurring to the user's experience. The EXE is
written in VC++, and I am aware of the IAccessible interface, but I'm not
sure where to start for finding a solution to such a need.
 
J

Jeff Mastry

The MailItem object has a SaveAs method that saves the message to a file in a
specified format. It will display a warning to the user.

-Jeff
 
A

ATS

Thanks for the reply,

Is the MailItem object accessible from IAccessible. For example, could I use
similar code to get the MailItem object from a HWND of Outlook:

IAccessible *pIAccessible = NULL;
IServiceProvider *pIServiceProvider = NULL;
IMailItem *pIMailItem = NULL;

AccessibleObjectFromPoint(*pPOINT, &pIAccessible, &cvTemp);
pIAccessible->QueryInterface(IID_IServiceProvider, (void **)
&pIServiceProvider);
pIServiceProvider->QueryService(IID_IMailItem, IID_IMailItem, (void **)
&pIMailItem);
 
J

Jeff Mastry

Unfortunately, I'm not familiar with IAccessible, so I can't answer your
question with any degree of certainty.

-Jeff
 
A

ATS

IThanks for the reply, but I'm still missing a "SaveToFile" method that
saves selected or opened emails to a file. Such as to an EML or MSG format.
The interfaces that article shows do not seem to have such a thing as the
Outlook's File-Save-As menu option. There are things like
IMAPISessionSite::SaveMessage, but that method saves the email to the Outlook
"draft" folder. And searches for anything in MSDN on SaveMessage, SaveToFile,
SaveEmail, etc just come up as either something only dealing with the
Outlook's save to folder/draft, with no options to save as an EML or MSG
file, or even in one instance IMimeBody has a SaveToFile which saves attached
documents to file, but that is still not the same thing.

I should have been more specific with my title, sorry about that. I should
have titled it as "HOWTO Programmatically save Outlook emails to file just
like Outlook's File-Save-As does to let one save emails as EML or MSG files
but to do so without any GUI".

Any ideas of where to go now?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top