Solved

Outlook, add/modify contacts with MAPI (Delphi7)

Posted on 2011-02-24
5
880 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Granting full access permission allows users to access mailboxes present in their database. By giving full access permission one can open and read the content of any mailbox but cannot send emails from that mailbox.
Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
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 …

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now