Log in

View Full Version : How to save attachments and move email using Rules



djchou
10-09-2007, 01:45 PM
Hi,

I've tried creating a rule that runs a script every time an email is sent to a email distribution.

For some reason, the rule does not save the attachments. Can someone please help?!

Sub attachmentrule(item As Outlook.MailItem)
Dim atmt As Attachment
Dim i As Integer

If item.Attachments.Count > 0 Then
For i = 1 To item.Attachments.Count
If Right(atmt.FileName, 3) = "xls" Then
FileName = "T:\Operations\Excel Attachments\" & Format(item.ReceivedTime, "yyyymmdd_hhnnss_") & atmt.FileName
atmt.SaveAsFile FileName
End If
Next
End If
Set atmt = Nothing

End Sub

Oorang
10-10-2007, 07:03 AM
:welcome:
Hi djchou,
Welcome to the board :)

We already have a thread ongoing on this:

http://www.vbaexpress.com/forum/showthread.php?t=15438