outlook attatchments

M

MANDLA MKHWANAZI

How can i check for a certain email if it has an attatchment then save it on
the external drive: i have this code which i did put on the outlook emial
as a mircro but its not working :

Dim WithEvents objInbox As Outlook.Items
Private Sub Application_Startup()
Set objInbox = Session.GetDefaultFolder(olFolderInbox).Items

End Sub
Private Sub objInbox_ItemAdd(ByVal item As Object)
If item.Class = olMail And item.Subject = "Test" Then
If item.Attachments.Count > 0 Then
Dim objattachments As Outlook.Attachment
Set objattachments = item.Attachments
For Each objattach In objattachments
objattach.SaveAsFile "c:\test\" & objattach.FileName
Next
Set objattachments = Nothing

End If


End If

End Sub
 

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