Outlook, add/modify contacts with MAPI (Delphi7)
Posted on 2011-02-24
I have an application that synchronizes data from a database with the contacts of outlook. That's ok. Now I have an installation with more than one profile in outlook and I have to sync. with only one of them. I tried it with "MapiLogon" but I don't know how to implement it. Can somebody help please?
With my code I have the following result (two profiles, "outlook" and "Test"):
Outlook not startet or profile "Test" started: the contacts are modified in profile "Test" (correct)
Outlook with profile "outlook" stated: the contacts are modified/added in profile "outlook" (wrong).
My code (only the part to select the profile):
OutlookApp := CreateOleObject('Outlook.Application');
Mapi := OutlookApp.GetNameSpace('MAPI');
if MapiLogOn(0,PAnsiChar('Test'),'',MAPI_NEW_SESSION,0,@hSession) <> 0 then
result := 0;
FormicaContacts := MAPI;
Any ideas? Thanks, Peter