Solved

Outlook, add/modify contacts with MAPI (Delphi7)

Posted on 2011-02-24
5
889 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
  • 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 Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

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…
Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

777 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