Saving attcahments to a folder with a rule.

  • Thread starter Thread starter grigoimayson
  • Start date Start date
G

grigoimayson

I want a rule to do the following:

Validate a message by a word in the subject -

Then to save the attachment in that message to a specific folder on my
system.

Also if it is possible to re-name a portion of the file name the same
as the sender's name.

If anyone can help me with this that would be great.

Thanks,

Ryan
 
Am 23 Jul 2006 21:06:48 -0700 schrieb (e-mail address removed):

For new incoming e-mails you can use the ItemAdd event of the Inbox. With
Instr you can check for a substring of the item´s Subject property. The item
has an Attachment collection, you can call each attachment´s SaveAsFile
property with the directory and file name you want the file to be saved as.

For the sender´s name read the e-mail´s SenderName property.
 
Here is a sample macro to save attachments to the SELECTED email to a folder
with the sender's name. It could be adapted to work as a rule, and you would
probably want to add some trapping for the case when the filename already
exists in the destination folder:

Sub AttSave()
Dim myItem As Outlook.MailItem
Dim myattachments As Outlook.Attachments
Dim myIndex

Set myItem = Outlook.ActiveExplorer.Selection.Item(1)
Set myattachments = myItem.Attachments
myIndex = 1

ChDir ("C:\")
On Error Resume Next
MkDir (myItem.SenderName)

For Each Item In myattachments
Item.SaveAsFile "C:\" & myItem.SenderName & "\" &
myattachments.Item(myIndex).DisplayName
myIndex = myIndex + 1
Next

End Sub
 
Back
Top