Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook Attachment Script help 1

Status
Not open for further replies.

Merle11

MIS
Apr 9, 2007
3
Hey All, I am in the process of developing an HTA and one of my subdirectories involves a script where I extract attachments from my Outlook email. I got the script to work fine but right now it extracts all attachments from my inbox. What I want it to do is to extract attachments only from a certain sender. Here is my code

Const olFolderInbox = 6

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox)

Set colItems = objFolder.Items

For Each objMessage in colItems
intCount = objMessage.Attachments.Count
If intCount > 0 Then
For i = 1 To intCount
objMessage.Attachments.Item(i).SaveAsFile "C:\reports\" & _
objMessage.Attachments.Item(i).FileName

Next

 
You may test the SenderEmailAddress property of the MailItem object:
If intCount > 0 [!]And objMessage.SenderEmailAddress = "someone@domain.com"[/!] Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top