views:

11

answers:

1

Suppose i have my mailbox configured and i have a special folder for mails with attachments in outlook 2007. What i want to do is i. either configure outlook to save the attachment of mails coming in a specified folder (Mails with Attachments) to specific folder in my computer drive in a desired folder

ii. Or if i can write some macro or script to copy those all to my computer location. If so can you please give me quick overview or refer me some where.

A: 

The code below will save attachments to a directory automatically. Use Outlook rules to run this macro automatically on each incoming message.

Sub AutoSaveAttachment(Item As Outlook.MailItem)
    Dim olAtt As Attachment
    Dim i As Integer
    Dim FIleNamewithDate As String
    Const FILE_PATH As String = "C:\"

    If Item.Attachments.Count > 0 Then
        For i = 1 To Item.Attachments.Count
            Set olAtt = Item.Attachments(i)
            olAtt.SaveAsFile FILE_PATH & olAtt.FileName


        Next i
    End If

    Set olAtt = Nothing

End Sub
Brendan