Results 1 to 2 of 2
2001-05-18, 18:16 #1JustCallMeAlGuest
Print from Word Outlook Last E-Mail Sent
I have no idea even where to start on this one....not really, but that is how I am feeling.
From a Word 97 VBA procedure, I need to print the last sent e-mail sent by Outlook.
This is part of a larger project where we can guarantee that the last e-mail sent by Outlook is the one we want.
The printed product must look the same as if the user went to Outlook, Sent Items, and printed the last e-mail.
Thanks for any assistance. I have no idea even how to head. The Outlook object is a mystery to me. [img]/forums/images/smilies/smile.gif[/img]
2001-05-20, 07:10 #2JustCallMeAlGuest
Re: Print from Word Outlook Last E-Mail Sent
Well after a lot of searching, I finally found a solution. This works in Word 2000 with Outlook 2000. I have my doubts if it will work in Outlook below 2000. Anyway, here it is. Hopefully it will assist someone else with an Outlook project. VBA in Outlook is very weird.
On Error Resume Next
Set objOutlook = GetObject(, "Outlook.Application")
If objOutlook Is Nothing Then
Set objOutlook = CreateObject("Outlook.Application")
On Error GoTo 0
Set myNameSpace = objOutlook.GetNameSpace("MAPI")
' The 5 in the next line is for olFolderSentMail
Set MyLastSentMessage = myNameSpace.GetDefaultFolder(5).items.getlast
' Rem the above line to not display the message.
' Remove rem from below line to print the message.
Set objDoc = Nothing
Set objOutlook = Nothing
Set myNameSpace = Nothing
Set MyLastSentMessage = Nothing