Hi,
Found the code below that is excellent, how can I modify to prompt for the date to retrieve the emails instead of fix date in the code:
Thank you
Found the code below that is excellent, how can I modify to prompt for the date to retrieve the emails instead of fix date in the code:
VBA Code:
Sub ExtractMailsFromOutlook()
Dim OutApp As New Outlook.Application 'early binding
Dim OutNamespace As Namespace, OutFolder As MAPIFolder, OutItem As Object
Dim r As Integer, cutDate As Date
Set OutNamespace = OutApp.GetNamespace("MAPI")
Set OutFolder = OutNamespace.GetDefaultFolder(olFolderInbox)
[B][COLOR=rgb(226, 80, 65)] cutDate = "01/01/2024"[/COLOR][/B]
On Error Resume Next
For Each OutItem In OutFolder.Items
If OutItem.ReceivedTime >= cutDate Then
r = r + 1
Range("A" & r + 1).Value = OutItem.ReceivedTime
Range("B" & r + 1).Value = OutItem.SenderName
Range("C" & r + 1).Value = OutItem.Subject
Range("D" & r + 1).Value = OutItem.Body
End If
Next OutItem
On Error GoTo 0
Set OutFolder = Nothing
Set OutNamespace = Nothing
Set OutApp = Nothing
End Sub
Thank you