Author |
Message |
Goof #1 / 10
|
 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 |
|
 |
Ken Slovak - [MVP - Outlook #2 / 10
|
 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 |
|
 |
Ritt Keerat #3 / 10
|
 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 |
|
 |
Dmitry Streblechenk #4 / 10
|
 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 |
|
 |
Dmitry Streblechenk #5 / 10
|
 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 |
|
 |
Dmitry Streblechenk #6 / 10
|
 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 |
|
 |
Goof #7 / 10
|
 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 |
|
 |
Dmitry Streblechenk #8 / 10
|
 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 |
|
 |
Dmitry Streblechenk #9 / 10
|
 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 |
|
 |
Goof #10 / 10
|
 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 |
|
|