View Single Post
  #3  
Old June 7th 06, 08:08 PM posted to microsoft.public.outlook.program_vba
Dan over in IT
external usenet poster
 
Posts: 2
Default 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

Ads