Long story: I've managed quite a few tasks with the extended Mapi libary from http://www.codeproject.com/Articles/10881/MAPIEx-Extended-MAPI-Wrapper. The problem is, it does not send the actual messages if Outlook is not running, it stores the messages in the outbox though, and to send them with a libary function require a login with a profile which I'll not alwas have.
Short story: I need to start an installed Outlook (did already check) with its default profault profile so that it can send the messages in it's outbox, if any.
There are very mice and slick solutions in C#, 2 to 6 lines of Code but unfortunately I have to stick to unmanaged VC++.
First try: I've already done quite a few things with the WIN32 OLE Interface and Microsoft Word. This time I only want the program to start, if not already running. So I tried
// Outlook Test
CoInitialize(NULL);
CLSID clsid;
HRESULT hr = CLSIDFromProgID(L"Outlook.Application", &clsid);
IDispatch *pOApp;
if(SUCCEEDED(hr))
{
IUnknown *pUnk;
hr = GetActiveObject(clsid, NULL, (IUnknown**)&pUnk);
if(FAILED(hr))
{
hr = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER,
IID_IDispatch, (void **)&pOApp);
if(FAILED(hr)) pOApp=NULL;
}
else if(pUnk)
{
hr = pUnk->QueryInterface(IID_IDispatch, (void **)&pOApp);
if(FAILED(hr)) pOApp=NULL;
}
}
But something is still missing.
I really appreciate any help you can provide
You may consider using a raw Extended MAPI code in unmanaged C++ without even automating Outlook. Moreover, in case of using the Outlook object model you will get a security prompt which the Send method triggers. You can read about this in the Outlook "Object Model Guard" Security Issues for Developers article.
See How To Create a Message With an Attachment and Send It Using MAPI/VC++ for the sample in C++ (Extended MAPI).