Using OSM in MFC/C++ Standalone App

Add-in Express™ Support Service
That's what is more important than anything else

Using OSM in MFC/C++ Standalone App
 
Rick


Guest


Hi,
I have purchased your product. I am writing a standalone, MFC/C++ app that makes Simple MAPI calls which invoke the MS Security Warnings Prompt. I want to use your product to avoid the prompts. I am building with MSVC++ 6.0.

I have integrated your ActiveX control into my app. I believe that I can
successfully execute most of the osm methods as shown below.

Here is my problem:
I don't know how to use C++ language to connect to MS Outlook. Since this
is a standalone app, I need to call m_osm.ConnectTo() but I need substantial help in doing this. I would prefer sample code that demonstrates how to setup and call the 'ConnectTo' function.

The function prototype is:
void COutlookSecurityManager::ConnectTo(const VARIANT& OutlookApp)
How do I setup the VARIANT parameter OutlookApp using C++.

Below is pseudo code demonstrating how I intend to use your product.

void COSMCheck2Dlg::OnButtonallow()
{
HRESULT hr ;

// OSM only seems to work for SimpleMAPI if MAPIInitialize is called first.
hr = MAPIInitialize(NULL) ;

// Check all capabilities but I only need osmSimpleMAPI to work.
hr = m_osm.Check(osmObjectModel) ; // returns hr = 1, this is OK for my app.
hr = m_osm.Check(osmCDO) ; // returns hr = 4, this is OK for my app.,
hr = m_osm.Check(osmSimpleMAPI) ; // returns hr=1 if MAPIInitialize not called.
// returns hr=0 with MAPIInitialize called - GOOD!

if(hr == osmOK)
{
hr = m_osm.GetDisableSMAPIWarnings() ;
if(hr == FALSE)
{
// enter here only if Prompts enabled (hr=0).
m_osm.SetDisableSMAPIWarnings(TRUE) ; // Disable the prompts
hr = m_osm.GetDisableSMAPIWarnings() ; // hr=1, GOOD! Verifies functions work.
}
}


-->// HELP: How do I 'm_osm.ConnectTo()' Outlook in a C++/MFC app?? I need sample code.
// I don't know how to connect to 'Outlook.Appliction' using C++. I see many
// samples on the forum using VB but I need C++.
// -- Sample Code goes here, please --



// Now, SimpleMAPI calls to be made to Outlook Profile (Inbox).
// MAPILogon(NULL, logon_name, NULL, MAPI_NEW_SESSION, 0, &session) ;
// MAPIReadMail, MAPISendMail

MAPIUninitialize() ;
return ;

}


Thank you.
Posted 30 Sep, 2005 15:12:55 Top
Dmitry Kostochko


Add-in Express team


Posts: 2745
Joined: 2004-04-05
Hi Rick,

The ConnectTo method must be called only if working with the Outlook Object Model (DisableOOMWarnings property). Since you work with Simple MAPI you don't need this method.

Posted 02 Oct, 2005 07:16:26 Top
Rick


Guest


Thanks Dmitry. Today, I tried MAPISendMail call without using ConnectTo and the OSM seemed to block the Security Warnings. I am pleasantly surprised. ;-}

-Rick
Posted 03 Oct, 2005 21:25:18 Top