?
Solved

Outlook, add/modify contacts with MAPI (Delphi7)

Posted on 2011-02-24
5
Medium Priority
?
898 Views
Last Modified: 2012-05-11
Hi

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');
      try
        Mapi := OutlookApp.GetNameSpace('MAPI');
        if MapiLogOn(0,PAnsiChar('Test'),'',MAPI_NEW_SESSION,0,@hSession) <> 0 then
        begin
          result := 0;
          Exit;
        end;
        FormicaContacts := MAPI;
        ...

Any ideas? Thanks, Peter
0
Comment
Question by:formi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 34972133
Hi, formi.

I don't know Delphi, but I can show you the correct way to do this using VB.  If you know VB, then hopefully you could translate that into Delphi.  Would that help?
0
 

Author Comment

by:formi
ID: 34977353
Hi BlueDevilFan

yes I know VB and it would be great to get your advice.

Peter
0
 
LVL 76

Accepted Solution

by:
David Lee earned 2000 total points
ID: 34985231
Peter,

Here's the code.  This sample assumes that Outlook is not running.  Keep in mind that Outlook can only open one profile at a time.  It cannot open two different profiles.
Dim olkApp, olkSes
Set olkApp = CreateApplication("Outlook.Application")
Set olkSes = olkApp.GetNameSpace("MAPI")
olkSes.Logon "Test"

Open in new window

0
 
LVL 101

Expert Comment

by:mlmcc
ID: 35213383
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
New style of hardware planning for Microsoft Exchange server.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question