Forum Discussion
JoshuaHughes1
Dec 12, 2024Copper Contributor
Excel pulls data from Outlook
Hello, We currently have an excel sheet which we access input the previous days date, todays date and hit a button and it shows all the incoming mail into a teams outlook mailbox. This is an o...
Kidd_Ip
Dec 15, 2024MVP
Please refer on below:
Sub GetEmails()
Dim OutlookApp As Object
Dim OutlookNamespace As Object
Dim Folder As Object
Dim Item As Object
Dim i As Integer
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
Set Folder = OutlookNamespace.Folders("YourMailboxName").Folders("Inbox")
For i = Folder.Items.Count To 1 Step -1
Set Item = Folder.Items(i)
If Item.ReceivedTime >= Range("StartDate").Value And Item.ReceivedTime <= Range("EndDate").Value Then
' Process the email
End If
Next i
JoshuaHughes1
Dec 16, 2024Copper Contributor
Thank you for the reply - where do i input this?