hoe to get the recipient name and attachment

A

Archon

I'd like to generate some report using excel, this report should
include the from, to, and cc fields, it should also include any
attachment name. In brief, i want to know who send what to whom.
Here is my code at the moment:
Sub report()
'variables
Dim strFrom As String
Dim strTo As String
Dim strAttachment As String
Dim bAttachment As Boolean

'setting mailitem object for sender and recipient
Set olApp = CreateObject("Outlook.Application")

Set NameSpace = olApp.GetNamespace("MAPI")
Set folder = NameSpace.GetDefaultFolder(olFolderInbox)



For i = 1 To folder.Items.Count Step 1
Set mail = folder.Items(i)
strFrom = mail.SenderName
Set myinspector = olApp.ActiveInspector
If Not TypeName(myinspector) = "Nothing" Then
If TypeName(myinspector.CurrentItem) = "MailItem" Then
Set myitem = myinspector.CurrentItem
Set myAttachments = myitem.Attachments
strAttachment = myAttachments.Item(i).DisplayName
End If
MsgBox "The item is of the wrong type."
End If
Display = MsgBox(strFrom + strTo + strAttachment, vbOKOnly,
"report")

Next i

End Sub
So... I can get the from field but still searchinghow to display the
"to" and "cc" fields and my attachment name or not displaying cause
myinspector is always nothing...
thanks for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top