Sub Emails_In_Inbox()
'***************************************************************
'* Set a refernce to the Outlook before running this procedure *
'* *
'* This will list all of the emails in the Inbox onto the *
'* current sheet, be sure to have an empty sheet selected *
'***************************************************************
' Variable Declaration
Dim inbox As Outlook.MAPIFolder, user As String
Dim i As Integer, mail As Integer, mails As Integer
Application.ScreenUpdating = False
Cells.Delete
' Headings
[A1] = "From": [B1] = "Subject": [C1] = "Attachments": [D1] = "Recieved"
With [A1:D1].Font
.Bold = True
End With
Application.Calculation = xlCalculationManual
Set inbox = GetObject("", "Outlook.Application") _
.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
mails = inbox.Items.Count
i = 0: mail = 0
' Extract Email Information
Do While i < mails
i = i + 1
With inbox.Items(i)
mail = mail + 1
Cells(mail + 1, 1).formula = .SenderName
Cells(mail + 1, 2).formula = .Subject
Cells(mail + 1, 3).formula = .Attachments.Count
Cells(mail + 1, 4).formula = Format(.ReceivedTime, "dd.mm.yyyy hh:mm")
End With
Loop
' Clean Up
Set inbox = Nothing
Columns("A:D").AutoFit
[A1].Select
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub