I cannot test properly as I don't get emails from an Internal Exchange, but try this modification;
![]()
Option Explicit Public Sub ReadOutlookEmails() 'Microsoft Outlook XX.X Object Library is required to run this code Dim objFolder As Outlook.Folder Dim objNS As Outlook.Namespace Dim objMail As Outlook.MailItem Dim lCounter As Long Dim Count As Long Sheet1.Range("C:D") = "" Set objNS = Outlook.GetNamespace("MAPI") Set objFolder = objNS.GetDefaultFolder(olFolderInbox) On Error Resume Next For lCounter = 1 To objFolder.Items.Count Application.DisplayStatusBar = True Application.StatusBar = "Reading mail item number " & lCounter Set objMail = objFolder.Items.Item(lCounter) If objMail.ReceivedTime > Sheet1.Range("B1").Value + 1 Then Exit For End If If objMail.ReceivedTime >= Range("A1").Value Then Count = Count + 1 If objMail.SenderEmailType = "SMTP" Then Sheet1.Range("C" & Count).Value = objMail.SenderEmailAddress Else Sheet1.Range("C" & Count).Value = objMail.Sender.GetExchangeUser.PrimarySmtpAddress End If Sheet1.Range("D" & Count).Value = objMail.ReceivedTime End If Next On Error GoTo 0 MsgBox "Done", vbInformation Application.DisplayStatusBar = False End Sub
Bookmarks