I have a requirement to print a work order attached to an email which comes into a users mailbox. What I have done is;
1) created a folder specifically for the work order emails.
2) created an email rule which moves the relevant emails to the folder created in (1) above.
3) I have a macro which prints the attachments of the emails in the folder I created in (1) above.
What I need now is to automatically run the macro I have created? At the moment I have to manually run the macro.
Any ideas would be greatly appreciated. here is the code for my macro.
Public Sub PrintAttachments()
Dim Inbox As MAPIFolder
Dim Item As MailItem
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer
Set Inbox = GetNamespace("MAPI").GetDefaultFolder(olFolderInbo x).Parent.Folders.Item("Print Attach")
For Each Item In Inbox.Items
For Each Atmt In Item.Attachments
FileName = "C:\Temp\" & Atmt.FileName
Shell """C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe"" /h /p """ + FileName + """", vbHide
Set Inbox = Nothing