View Single Post
  #6  
Old March 3rd 08, 02:50 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Modify VBS Script for Outlook

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
If ((objMessage.SenderName = "Joe Fubar") OR _
(objMessage.SenderAddress = ")) Then

objMessage.Attachments.Item(i).SaveAsFile "C:\Temp\" & _
objMessage.Attachments.Item(i).FileName
End If
Next
End If
Next

You have to substitute the actual name and email address you want of course.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Massimo" wrote in message
...

MailItem.SenderAddress properties. Once you get each mail item in the
loop
use those properties:

For Each objMessage in colItems
If ((objMessage.SenderName = "Joe Fubar") OR _
(objMessage.SenderAddress = ")) Then

' do whatever with this one
End If



Thank you very much but I'm ignorant about VBS :-)
how can I modify the script with the new option ?

--------------------------------------------------
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:\Temp\" & _
objMessage.Attachments.Item(i).FileName
Next
End If
Next
--------------------------------------------------

Best Regards


Ads