Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get e-mail sender (and sent date and received date)

Status
Not open for further replies.

grnzbra

Programmer
Mar 12, 2002
1,273
US
I have the following which was based on an Access vba code


Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNameSpace("MAPI")

For Each m in objNamespace.Folders
....If m.Name = "Personal Folders" Then
........For Each n in m.Folders
............If n.Name = "InboxBackup" Then
................SET oFolder = n
................EXIT FOR
............END IF
........NEXT
....EXIT FOR
....END IF
NEXT

FOR EACH Item IN oFolder.items
....Set oMsg = item
....IF oMsg.Attachments.Count > 0 THEN
........Set atch = oMsg.Attachments
........FOR EACH atch IN oMsg.Attachments
............atch.SaveAsFile strSrcFldr & atch.FileName
........NEXT
....END IF
NEXT

This works very nicely for saving the attached files. However, I need to get the sender of the e-mail. In the VBA code, he uses oMsg.SenderName and it works there. However, when I try to use any kind of variation on oMsg.SenderName or oMsg.Sender, I get an error message saying that Sender is something that oMsg has available.

What do I need to do to get the sender information?
 
How about:

[tt]FOR EACH Item IN oFolder.items
....Set oMsg = item

For Each oMsg In oFolder.Items
Debug.Print oMsg.SenderName[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top