Solved

Outlook, add/modify contacts with MAPI (Delphi7)

Posted on 2011-02-24
5
893 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 500 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 100

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

735 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