I am trying to find out if it is possible, from within Excel, to grab attachments and save them as an OLEObject in a specific cell. The idea being I am searching a Outlook folder for emails with a specific subject and then capturing some data about each email.
The user wants to be able to know if any of the responses have an attachment. Which is easy enough. But I want to go a step further and capture that attachment in Excel for them to be able to read, without having to go back to the email in Outlook.
The code below gets all the data I need. I am just not sure how to get that attachment into a cell.
Oh and as I was typing this, had a thought, what if there are multiple attachments?
Any advice would be appreciated!
Also, I am using Office 2010
Thank you.
[VBA]
For Each Item In ofldr.Items
'Determine if the file is a MailItem or ReportItem and Put on Seperate Tabs
If TypeName(Item) = "MailItem" And Item.Subject Like "*" & theSubj & "*" Then
Worksheets(1).Activate
With ActiveSheet
.Cells(lMrow, 1) = Item.SenderName
.Cells(lMrow, 2) = Item.VotingResponse
If .Cells(lMrow, 2).Value = "" Then
.Cells(lMrow, 2) = ""
End If
.Cells(lMrow, 3) = Item.ReceivedTime
.Cells(lMrow, 4) = Item.Subject
.Cells(lMrow, 5) = Item.Body
If Item.Attachments.Count > 0 Then
'Current State
.Cells(lMrow, 6) = "Yes"
.Cells(lMrow, 6).Font.Color = vbRed
'Future/Desired State
Copy that attachment and put in .Cells(lMrow, 6) as an OLEObject
End If
End With
End If
[/VBA]