I get a daily email that contains a single text file attachment. What I want to do is when I receive the email to automatically save that attachment to a certain location.
At the moment I have written a macro that saves the attachment and added a button to my Outlook toolbar which i just click to run it. Can anyone tell me how I would get it to run when I receive the email (much like an Outlook rule)?
The macro code is below FYI:
--James
At the moment I have written a macro that saves the attachment and added a button to my Outlook toolbar which i just click to run it. Can anyone tell me how I would get it to run when I receive the email (much like an Outlook rule)?
The macro code is below FYI:
Code:
Sub SaveAWB()
Dim oApp As New Outlook.Application
Dim oItem As Object
Dim ok As Integer
On Error GoTo HandleErr
Set oItem = oApp.ActiveExplorer.Selection.Item(1)
If oItem.Attachments.Count > 0 Then
oItem.Attachments(1).SaveAsFile "V:\Customer_Care\Clientele\Projects\AWB\awb.csv"
ok = MsgBox("The file was successfully saved", , "AWB")
Exit Sub
Else
ok = MsgBox("The selected email does not contain any attachments", , "AWB")
Exit Sub
End If
HandleErr:
ok = MsgBox(Error(), , "AWB")
End Sub
--James