Check Profile info

  • Thread starter Thread starter MB34
  • Start date Start date
M

MB34

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.

(I am using Delphi but can translate the VBA, if needed)
 
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.

(I am using Delphi but can translate the VBA, if needed)

OK, found the answer based on a 7yr 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;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top