Log in

View Full Version : Printing a lot of emails



Lisa1121
02-12-2016, 09:24 AM
Hello! I am new here and apologize if someone already asked and answered this question (I could not find it when I searched).

I used to have a VBA Script that was (probably) pretty rudimentary for Outlook 7. It was:


SendKeys "+{F10}"

SendKeys "i"

SendKeys "{DOWN 3}"
SendKeys "{ENTER}"
SendKeys "{DOWN}"


SendKeys "^p"
SendKeys "{TAB 3}"
SendKeys "1"
SendKeys "{ENTER}"

Basically, this would allow me to categorize my email as printed, and then would print the first page email below it. I work at a law office and I get hundreds of emails everyday, all of which need to be tagged and printed. The problem is that my office recently upgraded to Outlook 2016 and now my script won't work. Could anyone help me with writing a new one? I know next to nothing about programming and I really need to get my emails printed and put in their proper files. Thank you so much in advance!

gmayor
02-13-2016, 02:09 AM
Frankly it is impossible to tell what your macro was doing, but SendKeys should be avoided. The following will categorize and print the selected message either with a named category or by selecting a category.


Option Explicit

Sub CategorizeAndPrint()
Dim olItem As MailItem
On Error GoTo err_Handler
Set olItem = ActiveExplorer.Selection.Item(1)

'Options ++++++++++++++++++++++
'olItem.Categories = "MyCategory" 'Enter the fixed category name
'Or show the dialog and pick a category
olItem.ShowCategoriesDialog ' Select the category you wish to use
'End of options +++++++++++++++

olItem.Save
olItem.PrintOut
lbl_Exit:
Set olItem = Nothing
Exit Sub
err_Handler:
MsgBox Err.Number & vbCr & Err.Description
Err.Clear
GoTo lbl_Exit
End Sub