Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   vba macro to print email and attachments outlook 2000 (http://www.outlookbanter.com/outlook-vba/16890-vba-macro-print-email-attachments.html)

Dan over in IT June 5th 06 05:05 PM

vba macro to print email and attachments outlook 2000
 
Hi All,

I'm writing a macro in vba for Outlook 2000. My users need to print an
email with all of it's attachments, and then flag the email for follow
up. I have the flagging all set, and the email prints with most of the
attachments. However, if there are 2+ excel files attached (i've only
noticed this with Excel) one of them will not print. It seems like
excel doesn't open and print fast enough to get to all of them, so one
of them is just skipped. Has anyone else experienced this problem, and
if so is there any way around it??

Thanks


Sue Mosher [MVP-Outlook] June 6th 06 07:12 PM

vba macro to print email and attachments outlook 2000
 
Show your code for printing the attachments?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Dan over in IT" wrote in message oups.com...
Hi All,

I'm writing a macro in vba for Outlook 2000. My users need to print an
email with all of it's attachments, and then flag the email for follow
up. I have the flagging all set, and the email prints with most of the
attachments. However, if there are 2+ excel files attached (i've only
noticed this with Excel) one of them will not print. It seems like
excel doesn't open and print fast enough to get to all of them, so one
of them is just skipped. Has anyone else experienced this problem, and
if so is there any way around it??

Thanks


Dan over in IT June 7th 06 08:08 PM

vba macro to print email and attachments outlook 2000
 
Hi Sue,

Public Sub PrintSelectedEmails()

Dim oOutlook As Outlook.Application
Dim oNamespace As Outlook.NameSpace
Dim oMailItem As Outlook.MailItem
Dim i As Long

Set oNamespace = Application.GetNamespace("MAPI")
For i = 1 To Application.ActiveExplorer.Selection.Count
Set oMailItem = Application.ActiveExplorer.Selection.Item(i) '
Select the selected item to flag it
oMailItem.FlagStatus = olFlagMarked ' Marks the flag
oMailItem.FlagRequest = "Follow up" ' Sets flag for follow up
oMailItem.Close olSave ' Saves the flag and closes
the message

Set oMailItem = Application.ActiveExplorer.Selection.Item(i) '
Select the selected item to print it
oMailItem.Body = oMailItem.Body ' modifying the body of the mail
item reformats it to Rich Text
oMailItem.PrintOut ' Print's out email using users preference
' For this to work properly with attachments,
users must specify so in print options
Pause (oMailItem.Attachments.Count)
oMailItem.Close (olDiscard) ' don't save the email in Rich Text
format, preserve original format

Next i

Set oMailItem = Nothing
Set oNamespace = Nothing

End Sub

There is my function, the pause routine just waits 3 * the number
passed in seconds and I did that so that the attachments would print at
least grouped with the email, instead of all the emails, then all the
attachments in random order. I've tried printing then flagging, so
that I only have to set the item once, but I change the format because
of the HTML issue, and I'm trying not to save it in RTF if I can avoid
that...

Thanks in advance for any help you can give.

Dan



All times are GMT +1. The time now is 03:47 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com