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?
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?