Forum Home
Press F1
 
Thread ID: 116021 2011-02-14 00:53:00 use email rule to print email attachment only chiefnz (545) Press F1
Post ID Timestamp Content User
1177918 2011-02-14 00:53:00 Hi guys,

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(olFolderInbox).Parent.Folders.I tem("Print Attach")

For Each Item In Inbox.Items
For Each Atmt In Item.Attachments
FileName = "C:\Temp\" & Atmt.FileName
Atmt.SaveAsFile FileName
Shell """C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe"" /h /p """ + FileName + """", vbHide
Next

Next

Set Inbox = Nothing
End Sub
chiefnz (545)
1177919 2011-02-15 00:25:00 If you are using outlook its quite easy to do it this way (just use their rules wizard for the rules):
You will need a running PC with outlook running as the target recipient (A slave PC I suppose you could call it).
In outlook on that PC go to File/Print
In the box that comes up check the box that says "Print attached files" - save that.
Set up a rule to print any new mail and maybe move to another folder/delete whatever

Now if you mail that user name it should just print - you will get the email printing though as well as the attachments.
To stop spam you could perhaps always check for some sort of text in the mail or subject heading...
robjg63 (13548)
1177920 2011-02-15 01:31:00 Thanks Rob, but I tried this initially. I do not want to print the email ONLY the attachments.

Cheers,
chiefnz (545)
1