Author |
Message |
Goof #1 / 15
|
 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 / 15
|
 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 / 15
|
 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 / 15
|
 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 / 15
|
 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 |
|
 |
Goof #6 / 15
|
 Obtaining SMTP Address from Global Address Book
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 03:26:23 GMT |
|
 |
Dmitry Streblechenk #7 / 15
|
 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 #8 / 15
|
 Obtaining SMTP Address from Global Address Book
Quote: > 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;
I have your Extended MAPI Delphi headers. But trying to use the code you posted, I can't get this to work...What am I doing wrong? I get errors marked below... var pProp : PSPropValue; MP : IMAPIProp; strAddress : String; i, j: Integer; myOlApp: Variant; myNameSpace: Variant; myAddressList: Variant; myAddressLists: Variant; myAddressEntries: Variant; myAddressEntry: Variant; begin myOlApp := CreateOleObject('Outlook.Application'); myNameSpace := myOlApp.GetNameSpace('MAPI'); MAPIInitialize(nil); myAddressLists := myNameSpace.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 // get Operator not applicable to this operand type MP:= myAddressEntry.MAPIOBJECT as IMailUser; except // get Operator not applicable to this operand type MP:= 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); end; {for} end; {if} end; {for} MAPIUninitialize; end;
|
Sun, 08 Aug 2004 05:39:39 GMT |
|
 |
Dmitry Streblechenk #9 / 15
|
 Obtaining SMTP Address from Global Address Book
try MP:= IUnknown(myAddressEntry.MAPIOBJECT) as IMailUser; except MP:= IUnknown(myAddressEntry.MAPIOBJECT) as IDistList; end; {try..except} Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool
Quote: > > 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; > I have your Extended MAPI Delphi headers. But trying to use the code you > posted, I can't get this to work...What am I doing wrong? > I get errors marked below... > var > pProp : PSPropValue; > MP : IMAPIProp; > strAddress : String; > i, j: Integer; > myOlApp: Variant; > myNameSpace: Variant; > myAddressList: Variant; > myAddressLists: Variant; > myAddressEntries: Variant; > myAddressEntry: Variant; > begin > myOlApp := CreateOleObject('Outlook.Application'); > myNameSpace := myOlApp.GetNameSpace('MAPI'); > MAPIInitialize(nil); > myAddressLists := myNameSpace.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 > // get Operator not applicable to this operand type > MP:= myAddressEntry.MAPIOBJECT as IMailUser; > except > // get Operator not applicable to this operand type > MP:= 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); > end; {for} > end; {if} > end; {for} > MAPIUninitialize; > end;
|
Sun, 08 Aug 2004 07:52:00 GMT |
|
 |
Goof #10 / 15
|
 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 #11 / 15
|
 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 |
|
 |
Goof #12 / 15
|
 Obtaining SMTP Address from Global Address Book
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 04:24:17 GMT |
|
 |
Dmitry Streblechenk #13 / 15
|
 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 #14 / 15
|
 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 |
|
 |
Ken Slovak - [MVP - Outlook #15 / 15
|
 Obtaining SMTP Address from Global Address Book
See the code samples at http://www.cdolive.com/cdo5.htm for ways to get the SMTP addresses of Message items using CDO. -- 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: > How do I do this?? I want to get SMTP address from contact item and email > item, both in MAPI.Message format. > Thanks, > -Ritt
|
Tue, 10 Aug 2004 00:14:04 GMT |
|
|