KungFu Keyboard
New Member
- Joined
- Oct 22, 2016
- Messages
- 26
Hi there,
I have a macro that extracts all outlook emails into an excel file. Is there a line of code or a setting that I can adjust to bypass Outlooks security popup that prompts me to "Allow" access for 1 minutes? Code as follows:
Sub GetFromOutlook()
Application.DisplayAlerts = False
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
Dim Lastrow As Long
Set OutlookApp = New Outlook.Application
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
Set OutlookRecipient = OutlookNamespace.CreateRecipient("email@email.com")
Set Folder = OutlookNamespace.GetSharedDefaultFolder(OutlookRecipient, olFolderInbox).Folders("Folder Name")
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
Regards,
Bernard
I have a macro that extracts all outlook emails into an excel file. Is there a line of code or a setting that I can adjust to bypass Outlooks security popup that prompts me to "Allow" access for 1 minutes? Code as follows:
Sub GetFromOutlook()
Application.DisplayAlerts = False
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
Dim Lastrow As Long
Set OutlookApp = New Outlook.Application
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
Set OutlookRecipient = OutlookNamespace.CreateRecipient("email@email.com")
Set Folder = OutlookNamespace.GetSharedDefaultFolder(OutlookRecipient, olFolderInbox).Folders("Folder Name")
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
Regards,
Bernard