Akshay_divecha
Board Regular
- Joined
- Mar 11, 2014
- Messages
- 70
Hello Experts,
Working to find a VBA code which can copy details from outlook to excel and below is the code but while run the code getting below error.
Pls help to advise what's wrong,
Working to find a VBA code which can copy details from outlook to excel and below is the code but while run the code getting below error.
Pls help to advise what's wrong,
VBA Code:
Sub GetFromOutlook()
Dim OutlookApp As Outlook.Application
Dim OutlookNamespace As Namespace
Dim Folder As MAPIFolder
Dim OutlookMail As Variant
Dim i As Integer
Set OutApp = CreateObject("outlook.application")
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
Set Folder = OutlookNamespace.GetDefaultFolder(olFolderInbox).Folders(“inbox”)
i = 1
For Each OutlookMail In Folder.Items
If OutlookMail.ReceivedTime >= Range(“Email_Receipt_Date”).Value And Date <= 1 - Feb - 2020 Then
Range("email_Subject").Offset(i, 0).Value = OutlookMail.Subject
Range(“email_Subject”).Offset(i, 0).Columns.AutoFit
Range(“email_Subject”).Offset(i, 0).VerticalAlignment = 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).VerticalAlignment = xlTop
Range(“email_CC”).Offset(i, 0).Value = OutlookMail.Body
Range(“email_CC”).Offset(i, 0).Columns.AutoFit
Range(“email_CC”).Offset(i, 0).VerticalAlignment = xlTop
i = i + 1
End If
Next OutlookMail
Set Folder = Nothing
Set OutlookNamespace = Nothing
Set OutlookApp = Nothing
End Sub