![]() |
Outlook, resolve the smtp address from mailitem
Hello,
To get the e-mail address from the inbox items you can do the following below. But if the e-mail comes from a smtp server the adddress will be like "/o=provider/ou=first/cn=recipients/cn=DelphiLover" Anybody know how to obtain the real address? Oh, don't just look on the web and come with a non-code, because I've tried them all and they all fail!! The source that you'll find will look like : "obj.GetAddressEntry(strAddressEntryID).Fields(Cdo PR_EMAIL).Value;" (where CdoPR_EMAIL = $39FE001E) and this will not work.
Delphi-Quellcode:
var obj: OleVariant;
emailaddress: string; Item,objMsgs, objFolder, objAddressEntry : OleVariant; begin obj := CreateOleObject('MAPI.Session'); obj.Logon('','',False,False); objFolder:=obj.Inbox; objMsgs:=objFolder.Messages; Item:=objMsgs.GetFirst; objAddressEntry:=Item.Sender; emailaddress:=objAddressEntry.Address; Showmessage(emailaddress); End; |
Re: Outlook, resolve the smtp address from mailitem
Hello,
I found a solution by opening the Outlook Global Address List (GAL) and check all the items and see if you can find that SMTP-string. If found then you can ask the GAL for the real address. I'm not going to publish the code, but you can find it on the web. like : ![]() In the code he is using a try..except to check the interface type.. I think better coding is to check the interface by the queryinterface:
Delphi-Quellcode:
Some of the examples (VB/Delphi/C) you can find will not work, but sometimes that's because the Delphi Server Outlook Component is adding the "Outlook8" unit in the Uses part of the source. (In Delphi 5 it does..) In this unit there are a lot of functions/procedures/properties that will be used by the example codes, but also a lot of functionality that is not in the outlook8. So, when you use this unit a lot of examples will not work. (and for some days you ask yourself why?!:-) To solve this problem you can add another unit called "Outlook2000". A lot of examples will work with this unit. You can use them both if you like.
Check:=IUnknown(myAddressEntry.MAPIOBJECT).QueryInterface(IMailUser,MP);
If Check=0 then MP:=IUnknown(myAddressEntry.MAPIOBJECT) as IMailUser else MP:= IUnknown(myAddressEntry.MAPIOBJECT) as IDistList;
Delphi-Quellcode:
Greetings,
Uses OleServer, Outlook8, Outlook2000;
Delphi Lover. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:03 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz