AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Outlook, resolve the smtp address from mailitem
Thema durchsuchen
Ansicht
Themen-Optionen

Outlook, resolve the smtp address from mailitem

Ein Thema von Delphi-Lover · begonnen am 25. Okt 2004 · letzter Beitrag vom 28. Okt 2004
Antwort Antwort
Delphi-Lover

Registriert seit: 19. Okt 2004
Ort: Amsterdam
30 Beiträge
 
Delphi 2005 Professional
 
#1

Outlook, resolve the smtp address from mailitem

  Alt 25. Okt 2004, 17:31
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;
Rob
  Mit Zitat antworten Zitat
Delphi-Lover

Registriert seit: 19. Okt 2004
Ort: Amsterdam
30 Beiträge
 
Delphi 2005 Professional
 
#2

Re: Outlook, resolve the smtp address from mailitem

  Alt 28. Okt 2004, 10:58
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 :

Outlook Addressbook

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:
Check:=IUnknown(myAddressEntry.MAPIOBJECT).QueryInterface(IMailUser,MP);
If Check=0 then MP:=IUnknown(myAddressEntry.MAPIOBJECT) as IMailUser
else MP:= IUnknown(myAddressEntry.MAPIOBJECT) as IDistList;
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.

Uses OleServer, Outlook8, Outlook2000; Greetings,

Delphi Lover.
Rob
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:20 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz