Extract email messages from outlook to excel with attachment(s) information

Keerthiv

New Member
Dear All,

I have this vba which will extract the outlook messages to excel however I am not sure how can extract the attachment information along with this. Requesting your help please

Sub GetFromOutlook()

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("Testing")

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

End Sub
 

jorismoerings

Well-known Member
Hi,

Can you describe your exact need a bit more extensive:
1. is there always just 1 attachement or could there be multiple attachement;
2. what's the type of information you want stored in the excel file, eg filename or ....
 
Last edited:

Keerthiv

New Member
Hi Joris,
Subject
Date
Sender
Email Text
Attachment(s)

<tbody>
</tbody>

Thank you much for immediate reply. I have provided the format with required fields (unable to attach the file).

1. Whatever files that the email has as an attachment to be downloaded
2. the attachment can be saved to a folder and link can be given here.

Option 1 would be much helpful
 

Some videos you may like

This Week's Hot Topics

Top