I have the following VBA Code and i am trying to figure out why it is not working. There are no error messages when i run the code but i get none of the informaiton that I am trying to pull from outlook when i know there are plenty of emials in there. I
have watched videos and read a few different formulas like this one and i am wondering if i need to put my email address in the code somewhere so it knows what email in outlook to pull from. Any advice would be appreciated.
Sub getDataFromOutlook()
Dim OutlookApp As Outlook.Application
Dim OutlookNameSpace As Namespace
Dim Folder As MAPIFolder
Dim OutlookMail As Variant
Dim i As Integer
Set OutlookApp = New Outlook.Application
Set OutlookNameSpace = OutlookApp.GetNamespace("MAPI")
Set Folder = OutlookNameSpace.GetDefaultFolder(olFolderInbox).Folders("DDQ")
i = 1
For Each OutlookMail In Folder.Items
If OutlookMail.ReceivedTime >= Range("Email_Receipt_Date").Value Then
Range("email_subject").Offset(i, 0) = OutlookMail.Subject
Range("email_subject").Offset(i, 0).Columns.AutoFit
Range("email_subject").Offset(i, 0).VerticalAlignmant = xlTop
Range("email_Date").Offset(i, 0).Value = OutlookMail.ReceivedTime
Range("email_Date").Offset(i, 0).Columns.AutoFit
Range("email_Date").Offset(i, 0).VerticalAlignment = xlTop
Range("email_Sender").Offset(i, 0).Value = OutlookMail.SenderName
Range("email_Sender").Offset(i, 0).Columns.AutoFit
Range("email_Sender").Offset(i, 0).VertricalAlignment = xlTop
Range("email_Body").Offset(i, 0).Value = OutlookMail.Body
Range("email_Body").Offset(i, 0).Columns.AutoFit
Range("email_Body").Offset(i, 0).VertricalAlignment = xlTop
i = i + 1
End If
Next OutlookMail
Set Folder = Nothing
Set OutlookNameSpace = Nothing
Set OutlookApp = Nothing
End Sub