Autoprint email (plain text, html, attachments) (with message rule and VBA)
From: Tom Van Overschelde (vanovers_at_hotmail.com)
Date: Mon, 13 Sep 2004 14:08:54 +0200
I have to print all incoming emails including attachments.
The idea was to create an inbox rule. There is a standard rule which allows
me to print an email. However the problem with this, is that no inline
attachments are printed (our client uses an html signature with an embedded
gif image). The message itself is printed, but the attachment is printed as
a box with an X.
The strange thing is, when I open myself the message and choose to print,
everything looks good on the paper. So I thought, if I can this do by hand,
with a VBA macro, this must also work. I experimented with some code,
changed things, security settings, tried almost everything, but I still get
no inline gifs on the paper:
Sub AutoPrint(Item As Outlook.MailItem)
'On Error Resume Next
Set objInsp = Item.GetInspector
Set colCB = objInsp.CommandBars
' Print toolbar button
Set objCBB = colCB.FindControl(, 2521)
If Not objCBB Is Nothing Then
Wait 2 'waits 2 seconds
'objCBB.Enabled = False
Set objCBB = Nothing
Set colCB = Nothing
Set objInsp = Nothing
A previous variant with item.printout didn't work. The message was printed,
but I've got the same result as with the code here above, so no inline
images are printed. I think this comes because the messages are html
formatted, and outlook passes the message to Internet Explorer to print out.
But Internet Explorer doesn't find the embedded GIF image (Outlook gives me
also the message to open first the email when I choose 'print' from the
inbox). So that's the reason that I used 'item.display' in my code to open
first the message en then print. When I do it by hand, it works perfectly.
But with an inbox rule and the code above, no inline images. How can I
arrange this? In a later stage, I want to print also some attachment types,
but this is not the priority for the moment.
Many thanks in advance!!
* I tested this on 2 different computers
* the emails are stored on an IMAP mailserver, and access with the IMAP
protocol on Outlook 2003 (updated to SP1)