Solved

Outlook, add/modify contacts with MAPI (Delphi7)

Posted on 2011-02-24
5
894 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

Windows running painfully slow? Try these tips..

Stay away from Speed Up Computer Programs that do more harm than good.
Try these tips instead.
Step by step instructions in trouble shooting Windows Performance issues.

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…
Changing a few Outlook Options can help keep you organized!
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
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: …

740 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