Export address format

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I recently wrote a Macro that went though my inbox and exported every
objMailItem.SenderEmailAddress to Excel. This allows me to capture a master
email list. With the SenderEmailAddress code my export gets the address in
the (e-mail address removed) format. My issue now is that in the bcc or cc
fields I often get the intended recipients alias as in“ Joe Schmo†but not
his address as in (e-mail address removed). (I assume that the one format is an object
of the other or something of the sort.)

I am perfectly happy to give up on doing this in vba. When I cut the
addresses that read something like “Schmo, Joe <[email protected]â€. > from the
cc or bcc field and paste anythere outside an Outlook address field I lose
the (e-mail address removed) format and only get the Schmo, Joe.

Ideas? I am using Outlook 2003 to get the objMailItem.SenderEmailAddress to
work….
 
Use the Recipients collection, not the Bcc or Cc fields, which return only display names (which is only sometimes the same as the address, depending on how the sender entered the recipient).
 
Ok I am learning but I am a hacker. (No not a hacker like Kevin Mitnick more
like a drunk frontier doctor with a rusty knife.) Enough about me….

I do not get it. Below is a chunk of what I am working on. I assume that I
am accessing the Recipient or Recipients object all wrong.





Dim objApp As Outlook.Application
Dim objNameSpace As Outlook.Namespace
Dim objRecipient As Outlook.Recipient
Dim objMAPIFolder As Outlook.MAPIFolder
Dim objMailItem As Outlook.MailItem



Sub FindData()

Set objApp = Outlook.Application
Set objNameSpace = objApp.GetNamespace(Type:="MAPI")
Set objRecipient = objMailItem.Recipients
Set objMAPIFolder =
objNameSpace.GetDefaultFolder(foldertype:=olFolderInbox)



Arrays, exports and so on…….

Sue,
Any help here is would be great. Also let me know if your book covers stuff
like this. If so I will order it today.

JTH
 
Recipients is a collection. To get information from each individual Recipient object, you need to iterate that collection, e.g.:

For Each objRecip in objMailItem.Recipients
MsgBox objRecip.Address
Next

You also need to flesh out your code below to actually instantiate an objMailItem before you start working with its properties. I presume you already have that from the work you did on exporting SenderName.

This is exactly the kind of basic building block that my book covers. You can read the outline at the URL below.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Bob Inwater said:
I do not get it. Below is a chunk of what I am working on. I assume that I
am accessing the Recipient or Recipients object all wrong.

Dim objApp As Outlook.Application
Dim objNameSpace As Outlook.Namespace
Dim objRecipient As Outlook.Recipient
Dim objMAPIFolder As Outlook.MAPIFolder
Dim objMailItem As Outlook.MailItem

Sub FindData()

Set objApp = Outlook.Application
Set objNameSpace = objApp.GetNamespace(Type:="MAPI")
Set objRecipient = objMailItem.Recipients
Set objMAPIFolder =
objNameSpace.GetDefaultFolder(foldertype:=olFolderInbox)
 
Back
Top