vba macro to print email and attachments outlook 2000

D

Dan over in IT

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
 
S

Sue Mosher [MVP-Outlook]

Show your code for printing the attachments?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
D

Dan over in IT

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top