Check Profile info

I need to know how to check, when the OL Object is instantiated, the default profile's email address.
We want to check to see if the email of the user logged into our application is the same as the one in
the default profile in OL.
LVL 26
Eddie ShipmanAll-around developerAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Eddie ShipmanConnect With a Mentor All-around developerAuthor Commented:
OK found the answer based on a 7ry old post of mine on DelphiPages:


uses ..., Outlook2000, MAPIDefs, MAPIUtil;
 
var
  pmOutlook:     _Application;
  NameSpace:     _NameSpace;
  DefaultUser:   Recipient;
  _AddressEntry: AddressEntry;
  pProp:         PSPropValue;
  MP:            IMAPIProp;
  strAddress:    String;
begin
  try
    pmOutlook    := GetActiveOleObject('outlook.application') as _Application;
  except
    try
      pmOutlook  := CreateOleObject('outlook.application') as _Application;
    except
      on e:EOleSysError do
        ShowMessage('Cannot Load Outlook:' + E.Message);
    end;
  end;
  try
    Namespace   := pmOutlook.GetNamespace('MAPI');
    MAPIInitialize(nil);
    try
      DefaultUser := NameSpace.CurrentUser;
      if DefaultUser.Address <> '' then
      begin
        _AddressEntry := DefaultUser.AddressEntry;
        MP:= IUnknown(_AddressEntry.MAPIOBJECT) as IMailUser;
        if S_OK = HrGetOneProp(MP, $39FE001E, pProp) then
        begin
          strAddress:=pProp.Value.lpszA;
          MAPIFreeBuffer(pProp);
        end;
        ListBox1.Items.Add(_AddressEntry.Name + ' : ' +  strAddress);
        Application.ProcessMessages;
      end; {if}
    finally
      MAPIUninitialize;
    end;
  finally
    pmOutlook.Application.Quit;
    pmOutlook     := Unassigned;
    Namespace     := Unassigned;
    DefaultUser   := Unassigned;
    _AddressEntry := Unassigned;
  end;
end;

Open in new window

0
 
Geert GOracle dbaCommented:
OL  ???
0
 
Eddie ShipmanAll-around developerAuthor Commented:
Outlook
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
Eddie ShipmanAll-around developerAuthor Commented:
Sorry, I posted the same message to the Outlook VBA newsgroup and forgot to change it for this
Delphi TA.
0
 
Geert GOracle dbaCommented:
hehe,
i guess you're better that you thought yourself ...
0
 
Eddie ShipmanAll-around developerAuthor Commented:
Yeah, I was surprised I found the post.
0
 
Geert GOracle dbaCommented:
congrats on your top position ...

EddieShipman-Aced.png
0
 
Eddie ShipmanAll-around developerAuthor Commented:
LOL, what happened to 1-4???
0
 
Eddie ShipmanAll-around developerAuthor Commented:
Look at the bottom, that's where they are:
overall.png
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.