Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Extract eMail sender address from Outlook
Message
From
16/01/2001 12:55:58
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Extract eMail sender address from Outlook
Miscellaneous
Thread ID:
00464284
Message ID:
00464284
Views:
70
How can I extract the eMail sender address from Outlook via Automation? It seems that Outlook provides a sender name, if the sender of the mail item is contained in the address collection. I fiddled around with an CDO approach, but due to lacking knowledge I managed to crash VFP by executing the code below - though it delivers the desired result before going down.

Any ideas?

TIA Robert Stralka
#define OUTL_FOLDER_INBOX 6


LOCAL loOutl,loNS,loInbox,loMapiSession,i


loOutl        = CREATEOBJECT('Outlook.Application')
loNS          = loOutl.GetNameSpace('MAPI')
loInbox       = loNS.GetDefaultFolder(OUTL_FOLDER_INBOX)
loMapiSession = CREATEOBJECT('MAPI.Session')
loMapiSession.Logon(,,.F.,.F.)
FOR i = 1 TO loInbox.Items.Count
  ? getEmailAddress(loMapiSession,loInbox.Items(i))
ENDFOR
loMapiSession.Logoff()
loMapiSession = .NULL.
loInbox       = .NULL.
loNS          = .NULL.
loOutl        = .NULL.


FUNCTION getEmailAddress
  LPARAMETERS voMapiSession,voItem
  LOCAL loCDOItem,lcSenderEmailAddress

  WITH voItem
    loCDOItem = voMapiSession.GetMessage(.EntryID,.Parent.StoreID)
  ENDWITH
  lcSenderEmailAddress = loCDOItem.Sender.Address
  loCDOItem            = .NULL.
RETURN lcSenderEmailAddress
I've acquired quite a taste for a well-made mistake... [Fiona Apple]
Next
Reply
Map
View

Click here to load this message in the networking platform