🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #15812

Re: OutlookApplication and MAPI questions.

#15812
From: Peter Elbertse
Date: Fri, 13 Jun 2003 12:34
86 lines
5076 bytes
OK, continuing on my problem, I've created a menu-designer in which it is possible to place
shortcuts in the Applications Menu to locations within Outlook/Exchange...  This is done using the
following code:

                // Open the MAPI Object and display the Calandar:
                NameSpacePtr nSpace     = OutlookApplication->GetNamespace( WideString("MAPI") );

                // Select a MAPI Folder:
                MAPIFolderPtr mFolder = nSpace->PickFolder();

                // Show MAPI Store ID:
                CComVariant cvStoreID;
                mFolder->get_StoreID( &cvStoreID.bstrVal );
                FOutlookStoreID = String(cvStoreID.bstrVal);

                // Show MAPI Store ID:
                CComVariant cvEntryID;
                mFolder->get_EntryID( &cvEntryID.bstrVal );
                FOutlookEntryID = String(cvEntryID.bstrVal);

I was able to get the FolderID and the StoreID needed to connect to the correct folder (within the
"Public Folders" ) with afterwards.. This part works OK and so I've got the data required for the
shortcut. Whenever you click on the shortcut, the following code will be executed:

                        // Get the correct MAPI Folder:
                        mFolder = nSpace->GetFolderFromID(cvEntryID.bstrVal, cvStoreID);

The problem now is that for some reason MS/Outlook requires the user to have started Outlook first
(not the true case) and has clicked on the "Public Folders" tree. This because only than Outlook
will truely connect to the MS Exchange Information Store (the real problem).. Using the code above
before doing this will result in an error. Executing the code when a (doesn't matter which) folder
is selected and the "Public Folders" is just clicked on once in that Outlook session, the code will
be executed correctly.

So, my question is, does anyone know of a way to connect to the Information Store by code
(PickFolder does this seemably, but in this case I don't want to Pick a folder through GUI, but
through source)? And... Am I in the correct newsgroup here or should it be placed in
components.using or some other group?


Peter

"Peter Elbertse" <zoetjuh@wanadoo.nl> wrote in message news:3edcbf89$1@newsgroups.borland.com...
> Hello all,
>
> Today I've been trying to understand the TOutlookApplication. I want to open (if not allready
> opened) a single instance of Outlook and display the Calendar.
>
> Which the code below I managed to open it, but every time I execute the code it openes up a new
> Outlook window... I just want to reuse the existing one... Any help is appreciated.
>
> This code works, but generates new instances of the Outlook window:
>
>     //--------------------------
>     // Try to connect to outlook (using the existing instance if active):
>     OutlookApplication->Connect();
>
>     // Open the MAPI Object and display the Calendar:
>     NameSpacePtr nSpace     = OutlookApplication->GetNamespace( WideString("MAPI") );
>     MAPIFolderPtr mCalendar = nSpace->GetDefaultFolder(olFolderCalendar);
>     mCalendar->Display();
>     //--------------------------
>
> Now this code connects too, but errors on the Explorer assignment..
> I don't even know if this code would solve the multi-instances, but I thought it was worth to try:
>
>     //--------------------------
>     // Try to connect to outlook (using the existing instance if active):
>     OutlookApplication->Connect();
>
>     // Open the MAPI Object and display the Calendar:
>     NameSpacePtr nSpace         = OutlookApplication->GetNamespace( WideString("MAPI") );
>     MAPIFolder *mapiCalendar = nSpace->GetDefaultFolder(olFolderCalendar);
>     Explorers  *expCalendar       = OutlookApplication->Explorers;
>     Explorer   *exprCalendar       = expCalendar->Add( CComVariant(&mapiCalendar),
> olFolderDisplayNoNavigation);
>     exprCalendar->Display();
>     //--------------------------
>
>
> Best Regards,
>
>
> Peter Elbertse
>
>
Technical Details
Message-ID: <3ee9c4c4@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!38.144.126.76.MISMATCH!feed2.newsreader.com!newsreader.com!newshosting.com!news-xfer1.atl.newshosting.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3edcbf89$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,bb6a2675dacd778c
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-06-13 05:41:37 PST
From: "Peter Elbertse" <zoetjuh@wanadoo.nl>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3edcbf89$1@newsgroups.borland.com>
Subject: Re: OutlookApplication and MAPI questions.
Date: Fri, 13 Jun 2003 14:34:12 +0200
Lines: 88
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 212.238.183.121
Message-ID: <3ee9c4c4@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1055507652 212.238.183.121 (13 Jun 2003 05:34:12 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!38.144.126.76.MISMATCH!feed2.newsreader.com!newsreader.com!newshosting.com!news-xfer1.atl.newshosting.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail