Obtaining SMTP Address from Global Address Book 
Author Message
 Obtaining SMTP Address from Global Address Book

Is there a way to obtain the smtp address from an AddressEntry
in the Global Address Book without using CDO?


Tue, 03 Aug 2004 22:52:50 GMT  
 Obtaining SMTP Address from Global Address Book
Extended MAPI is the only other way I know of.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Quote:
> Is there a way to obtain the smtp address from an AddressEntry
> in the Global Address Book without using CDO?



Tue, 03 Aug 2004 22:59:28 GMT  
 Obtaining SMTP Address from Global Address Book
How do I do this??  I want to get SMTP address from contact item and email
item, both in MAPI.Message format.

Thanks,
-Ritt



Quote:
> Extended MAPI is the only other way I know of.

> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Lead Author, Professional Outlook 2000 Programming, Wrox Press
> Lead Author, Beginning VB 6 Application Development, Wrox Press
> Attachment Options
> http://www.slovaktech.com/attachmentoptions.htm
> Extended Reminders
> http://www.slovaktech.com/extendedreminders.htm



> > Is there a way to obtain the smtp address from an AddressEntry
> > in the Global Address Book without using CDO?



Fri, 06 Aug 2004 10:55:05 GMT  
 Obtaining SMTP Address from Global Address Book
Try AddressEntry.Fields(&H39FE001E)

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool


Quote:
> Is there a way to obtain the smtp address from an AddressEntry
> in the Global Address Book without using CDO?



Sun, 08 Aug 2004 02:23:15 GMT  
 Obtaining SMTP Address from Global Address Book
Sorry, I didn't catch that you don't want to use CDO. Ken is right, the only way
to do that is to use Extended MAPI. What language are you using? Extended MAPI
is C++/Delphi only.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool


Quote:
> Try AddressEntry.Fields(&H39FE001E)

> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy  - Outlook, CDO
> and MAPI Developer Tool



> > Is there a way to obtain the smtp address from an AddressEntry
> > in the Global Address Book without using CDO?



Sun, 08 Aug 2004 02:30:33 GMT  
 Obtaining SMTP Address from Global Address Book
If you don't have Delphi Extended MAPI headers, you can download them from my
site (url below, click OutlookSpy, then Resources). Once you have AddressEntry
Outlook object, try the code below:

var pProp : PSPropValue;
      MP : IMAPIProp;
      strAddress : string;
...
MAPIInitialize(nil);
try
  MP:=AddressEntry.MAPIOBJECT as IMailUser;
except
  MP:=AddressEntry.MAPIOBJECT as IDistList;
end;
if S_OK = HrGetOneProp(MP, $39FE001E, pProp) then begin
  strAddress:=pProp.Value.lpszA;
  MAPIFreeBuffer(pProp);
end;
MAPIUninitialize;

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool


Quote:

> > Sorry, I didn't catch that you don't want to use CDO. Ken is right, the only
way
> > to do that is to use Extended MAPI. What language are you using? Extended
MAPI
> > is C++/Delphi only.

> Delphi!



Sun, 08 Aug 2004 04:20:01 GMT  
 Obtaining SMTP Address from Global Address Book

Quote:
> try

    // Error - No such Interface supported!

Quote:
>   MP:= IUnknown(myAddressEntry.MAPIOBJECT) as IMailUser;
> except
>   MP:= IUnknown(myAddressEntry.MAPIOBJECT) as IDistList;
> end; {try..except}

Did you even try the code I posted?


Sun, 08 Aug 2004 23:38:57 GMT  
 Obtaining SMTP Address from Global Address Book
No, it is off the top of my head. What was the problem?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool


Quote:

> > try
>     // Error - No such Interface supported!
> >   MP:= IUnknown(myAddressEntry.MAPIOBJECT) as IMailUser;
> > except
> >   MP:= IUnknown(myAddressEntry.MAPIOBJECT) as IDistList;
> > end; {try..except}

> Did you even try the code I posted?



Mon, 09 Aug 2004 01:28:33 GMT  
 Obtaining SMTP Address from Global Address Book
This is a known problem if you call Init/Uninit functions without letting the
message pump run. Move MAPIInitialize() to the FormCreate() handler and
MAPIUninitialize() to the FormDestroy() handler.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool


Quote:

> > No, it is off the top of my head. What was the problem?

> I wanted to get SMTP addresses of Global AddressBook entries.

> I finally got this to work but I am getting an Access Violation in the
> MAPIUninitialize...

> unit Unit1;

> interface

> uses
>   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
>   Outlook2000, StdCtrls, OleAuto, MAPIDefs, MAPIUtil;

> type
>   TForm1 = class(TForm)
>     ListBox1: TListBox;
>     Button1: TButton;
>     procedure Button1Click(Sender: TObject);
>   private
>     { Private declarations }
>   public
>     { Public declarations }
>   end;

> var
>   Form1: TForm1;

> implementation

> {$R *.DFM}

> procedure TForm1.Button1Click(Sender: TObject);
> var
>   pProp : PSPropValue;
>   MP : IMAPIProp;
>   strAddress : String;
>   i, j: Integer;
>   myOlApp: Variant;
>   myNameSpace: Variant;
>   myAddressList: AddressList;
>   myAddressLists: AddressLists;
>   myAddressEntries: AddressEntries;
>   myAddressEntry: AddressEntry;
> begin
>   myOlApp := CreateOleObject('Outlook.Application');
>   myNameSpace := myOlApp.GetNameSpace('MAPI');
>   MAPIInitialize(nil);
>   myAddressLists := IUnknown(myNameSpace.AddressLists) as AddressLists;
>   for i := 1 to myAddressLists.Count do
>   begin
>     myAddressList := myAddressLists.Item(i);
>     if Pos('Global', myAddressList.Name) > 0 then
>     begin
>       myAddressEntries := myAddressList.AddressEntries;
>       for j := 1 to myAddressEntries.Count do
>       begin
>         myAddressEntry := myAddressEntries.Item(j);
>         try
>           // Error No such interface supported!!!
>           MP:= IUnknown(myAddressEntry.MAPIOBJECT) as IMailUser;
>         except
>           MP:= IUnknown(myAddressEntry.MAPIOBJECT) as IDistList;
>         end; {try..except}
>         if S_OK = HrGetOneProp(MP, $39FE001E, pProp) then
>         begin
>           strAddress:=pProp.Value.lpszA;
>           MAPIFreeBuffer(pProp);
>         end;
>         ListBox1.Items.Add(myAddressEntry.Name + ' : ' +
>                            {myAddressEntry.Address + ' :' +}
>                            strAddress);
>         Application.ProcessMessages;
>       end; {for}
>     end; {if}
>   end; {for}
>   MAPIUninitialize;
> end;

> end.



Mon, 09 Aug 2004 05:01:45 GMT  
 Obtaining SMTP Address from Global Address Book

Quote:
> This is a known problem if you call Init/Uninit functions without letting the
> message pump run. Move MAPIInitialize() to the FormCreate() handler and
> MAPIUninitialize() to the FormDestroy() handler.

That did it...you're a charm!!!


Mon, 09 Aug 2004 05:32:09 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Obtaining SMTP Address from Global Address Book

2. Global Address Book Addresses Being Converted from SMTP to EX

3. SMTP address versus EX address in Outlook Address Book/Contacts

4. SMTP address versus EX address in Outlook Address Book/Contacts

5. Obtaining email addresses from Global Address List

6. smtp email addresses in the Outlook global address list

7. smtp email addresses in the Outlook global address list

8. Printing SMTP in Global address book

9. Obtain Address Book For a given Address Entry within a Distribution List

10. Only showing SMTP addresses in Address book


 
Powered by phpBB® Forum Software © phpBB Group