Hi all,
I found and adapted the below macro which works perfectly for me.
However, I now need to add in a new column which provides the attachment name(s) on any of the emails and having tried an assortment of variations, I am not getting anywhere in the dimensions and sets to use.
Can anyone out there help?
Thanks
Philip
Sub IHFADMINMAILING()
Dim olApp As Outlook.Application
Dim olNS As Outlook.Namespace
Dim olFldr As Outlook.MAPIFolder
Dim olItem As Object
Dim olMailItem As Outlook.MailItem
Dim ws As Worksheet
Dim iRow As Long
Dim hdr As Variant
Set ws = ThisWorkbook.Worksheets("IHF ADMIN MAILING")
Set olApp = New Outlook.Application
Set olNS = olApp.GetNamespace("MAPI")
Set olFldr = olNS.Folders("IHF ADMIN MAILING")
Set olFldr = olFldr.Folders("Inbox")
Application.ScreenUpdating = False
ws.Cells.Clear
iRow = 2
With ws
hdr = Array("Sender", "Sender Email Address", "Sender Name", "Subject", "Received Time", "Categories", "Task Completed Date", "Folder", "")
.Range("A1").Resize(, UBound(hdr)) = hdr
End With
For Each olItem In olFldr.Items
If olItem.Class = olMail Then
Set olMailItem = olItem
With olMailItem
ws.Cells(iRow, "A") = .Sender
ws.Cells(iRow, "B") = .SenderEmailAddress
ws.Cells(iRow, "C") = .SenderName
ws.Cells(iRow, "D") = .Subject
ws.Cells(iRow, "E") = .ReceivedTime
ws.Cells(iRow, "F") = .Categories
ws.Cells(iRow, "G") = .TaskCompletedDate
ws.Cells(iRow, "H") = olFldr.Name
iRow = iRow + 1
End With
End If
Next olItem
With ws
.Columns.AutoFit
End With
Application.ScreenUpdating = False
MsgBox "IHF ADMIN MAILING BOX - Analysis Complete!"
End Sub
I found and adapted the below macro which works perfectly for me.
However, I now need to add in a new column which provides the attachment name(s) on any of the emails and having tried an assortment of variations, I am not getting anywhere in the dimensions and sets to use.
Can anyone out there help?
Thanks
Philip
Sub IHFADMINMAILING()
Dim olApp As Outlook.Application
Dim olNS As Outlook.Namespace
Dim olFldr As Outlook.MAPIFolder
Dim olItem As Object
Dim olMailItem As Outlook.MailItem
Dim ws As Worksheet
Dim iRow As Long
Dim hdr As Variant
Set ws = ThisWorkbook.Worksheets("IHF ADMIN MAILING")
Set olApp = New Outlook.Application
Set olNS = olApp.GetNamespace("MAPI")
Set olFldr = olNS.Folders("IHF ADMIN MAILING")
Set olFldr = olFldr.Folders("Inbox")
Application.ScreenUpdating = False
ws.Cells.Clear
iRow = 2
With ws
hdr = Array("Sender", "Sender Email Address", "Sender Name", "Subject", "Received Time", "Categories", "Task Completed Date", "Folder", "")
.Range("A1").Resize(, UBound(hdr)) = hdr
End With
For Each olItem In olFldr.Items
If olItem.Class = olMail Then
Set olMailItem = olItem
With olMailItem
ws.Cells(iRow, "A") = .Sender
ws.Cells(iRow, "B") = .SenderEmailAddress
ws.Cells(iRow, "C") = .SenderName
ws.Cells(iRow, "D") = .Subject
ws.Cells(iRow, "E") = .ReceivedTime
ws.Cells(iRow, "F") = .Categories
ws.Cells(iRow, "G") = .TaskCompletedDate
ws.Cells(iRow, "H") = olFldr.Name
iRow = iRow + 1
End With
End If
Next olItem
With ws
.Columns.AutoFit
End With
Application.ScreenUpdating = False
MsgBox "IHF ADMIN MAILING BOX - Analysis Complete!"
End Sub