KungFu Keyboard
New Member
- Joined
- Oct 22, 2016
- Messages
- 26
Hi there,
The following code works on Excel 2013 but wont work on Excel 2010:
I am getting compile errors.
What's the best way around this?
Regards,
Bernard
The following code works on Excel 2013 but wont work on Excel 2010:
Code:
Sub GetFromOutlook()
Dim OutlookApp As Outlook.Application
Dim OutlookNamespace As Namespace
Dim Folder As MAPIFolder
Dim OutlookRecipient As Outlook.Recipient
Dim OutlookMail As Variant
Dim I As Integer
Set OutlookApp = New Outlook.Application
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
Set OutlookRecipient = OutlookNamespace.CreateRecipient("ey@globalloadcontrol.com")
Set Folder = OutlookNamespace.GetDefaultFolder(olFolderInbox).Folders("Irregularity Reports")
I = 1
For Each OutlookMail In Folder.Items
If OutlookMail.ReceivedTime >= Range("From_date").Value Then
Range("eMail_subject").Offset(I, 0).Value = OutlookMail.Subject
Range("eMail_date").Offset(I, 0).Value = OutlookMail.ReceivedTime
Range("eMail_sender").Offset(I, 0).Value = OutlookMail.SenderName
Range("eMail_text").Offset(I, 0).Value = OutlookMail.Body
I = I + 1
End If
Next OutlookMail
Set Folder = Nothing
Set OutlookNamespace = Nothing
Set OutlookApp = Nothing
Set OutlookRecipient = Nothing
End Sub
What's the best way around this?
Regards,
Bernard
Last edited by a moderator: