Problems With Outlook 2013 VBA To Send and Print an email

Not open for further replies.


New Member
Outlook version
Outlook 2013 32 bit
Email Account
Exchange Server
We have a business need to send an email and then print the message once it has been sent.

(We operate in a regulated environment and the sent emails are stored in paper files......)

We initially tried the suggestions from

which pointed us in the right direction, but unfortunately did not actually work for us.

However, we DO have some VBA that DOES now work successfully BUT only when it is run in the code window (step-by-step).
If we run the VBA as the users will from a button on the outlook toolbar, then it fails, as the code to print the message is executed before the message is moved from the Outbox to Sent Items.

We have tried Wait statements, loops to check for the existence of the email in Sent Items etc and ALL work fine with the code window open - and all fail "in the real world".

The current code is attached - any help or suggestions gratefully received as always.

Kind regards


  • OutlookSendAndPrint.txt
    3.8 KB · Views: 396

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Have you tried this timer? -

Being the forgetful type, I'd use an ItemAdd macro so i didn't have to remember to use the button. It also insures the correct message is printed. If you don't want to print every message, add a dialog asking if they want to print it.

It lookslike you are checking the subject and to field before sending
If Len(obj.To) > 0 And Len(obj.Subject) > 0 Then
you don't need that with 2010 and 2013 - they check for blank subjects and outlook won't send mail with a blank to field.

Option Explicit
 Private WithEvents Items As Outlook.Items
  Dim strDirectory As String
 Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliSeconds As Long)
Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias _
  "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
  ByVal lpFile As String, ByVal lpParameters As String, _
  ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
 Private Sub Application_Startup()
 Set Items = Session.GetDefaultFolder(olFolderSentMail).Items
 End Sub

 Private Sub Items_ItemAdd(ByVal Item As Object)
  Dim intUserAnswer As Integer
Dim i As Long
  If TypeOf Item Is Outlook.MailItem Then
  If Item.Attachments.Count > 0 Then
  Select Case Item.Attachments.Count
  Case 1
  intUserAnswer = MsgBox("There is " & CStr(Item.Attachments.Count) & " attachment to this email. Do you wish to print it ?", vbYesNo)
  Case Else
  'More than one attachment
  intUserAnswer = MsgBox("There are " & CStr(Item.Attachments.Count) & " attachments to this email. Do you wish to print these ?", vbYesNo)
  End Select
  If intUserAnswer = vbYes Then
  PrintAttachments Item
  MsgBox "The attachments will not be printed"
  End If
  MsgBox "There are no attachments."
  End If

  End If
 End Sub
Public Sub PrintAttachments(Mail As Outlook.MailItem)
 On Error Resume Next
 Dim colAtts As Outlook.Attachments
 Dim oAtt As Outlook.Attachment
 Dim strFile As String
 Dim strFileType As String
strDirectory = "C:\Users\dianep\Documents\print\"
Set colAtts = Mail.Attachments
If colAtts.Count Then
  For Each oAtt In colAtts
  strFileType = LCase$(Right$(oAtt.FileName, 4))
  Select Case strFileType
  Case ".xls", ".doc", "xlsx", ".pdf", "docx"
  strFile = strDirectory & oAtt.FileName
  oAtt.SaveAsFile strFile
  ShellExecute 0, "print", strFile, vbNullString, vbNullString, 0
  Case Else
  'Do nothing
  End Select
 End If
 End Sub
Public Sub DeleteFiles()
'Call WaitTimer
Sleep 10000
'Delete file from folder
Kill strDirectory & "*.*"
End Sub
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
D Outlook 2013 Yahoo IMAP Sync problems Using Outlook 1
O Outlook 2013 Problems sending large mails Using Outlook 4
G Problems with Active Directory Rights Management Services (AD RMS) in Outlook 2013 Exchange Server Administration 0
L Outlook 2013 setup problems Exchange Server Administration 1
T Outlook 2013 and sync problems Using Outlook 5
R Outlook 2013 email folder sync problems using OneDrive Using Outlook 3
Jon Bakrley problems with outlook 2013 and pst files Using Outlook 4
C Outlook 2013 compatibility problems with outlook 2007 Using Outlook 3
G Outlook 2013 problems Using Outlook 2
V Outlook 2016 Outlook-2016 and iCloud for Windows - Problems Using Outlook 3
T Many problems with - will upgrade to Outlook soon Using Outlook 1
Q Problems with Autodiscover Outlook 2016 Using Outlook 0
M Indexing Problems Outlook 365 Using Outlook 2
C 2016 Outlook Certificate Problems Outlook VBA and Custom Forms 3
S Problems syncing emails with webmail after changing to Outlook 2016 Using Outlook 1
Diane Poremsky iCloud and Outlook Problems: Syncing Calendar New Articles 0
G Outlook problems Using Outlook 2
A Problems Opening Excel from Outlook Outlook VBA and Custom Forms 3
T Outlook Connector calendar sync problems with Android phone Using accounts in Outlook 1
J Outlook 2010 sync problems with Outlook Connector Using Outlook 1
B Outlook being closed causing problems during copy to Excel Outlook VBA and Custom Forms 6
A Problems with Outlook Connector in Outlook 2010 Using Outlook 2
J problems downloading POP3 emails to Outlook 2003 Using Outlook 1
M Outlook problems after yesterday's update Using Outlook 4
L Weird Inbox problems Outlook 2010/13 and Exchange Exchange Server Administration 2
P problems Using Outlook 0
D Outlook and Icloud problems Using Outlook 0
E Outlook 2010 network printing problems Using Outlook 4
P Encoding problems after synchronization with Outlook Connector Using accounts in Outlook 6
J problems with viewing aol emails in Outlook Using Outlook 3
B Problems with outlook calendar and android phone syncing calendars Using accounts in Outlook 1
P Sync Problems Outlook with iPad 2 Using Outlook 3
C migrating from Windows Live Mail over to Outlook 2010 Problems ... Using Outlook 2
J Outlook 2010 and Icloud multiple calenders problems. Using Outlook 10
T Outlook 2007 - iTunes - iCloud Sync Problems Using Outlook 7
S Public FolderEmail Sort Problems Outlook 2010/Migration from 2003 SBS to 2011S Using Outlook 3
S Outlook 2010 and certificate problems Using Outlook 9
M Several Problems using Outlook Using Outlook 3
W Outlook exp. 2007 problems - won't receive new mail Using Outlook 1
P Printing problems with MS Outlook 2000 Using Outlook 1
A Two strange calender problems in Outlook 2003 ... Using Outlook 2
T Outlook 2007 shut down problems Using Outlook 1
A Outlook Advanced Search Problems...returns with an Error: Argument Outlook VBA and Custom Forms 1
J Problems with Outlook.Recipient.Resolve Outlook VBA and Custom Forms 3
T Problems re-installing BCM for Outlook 2007 BCM (Business Contact Manager) 2
M Export-Import .pst file problems Using Outlook 2
V iCloud calendar sync problems Using Outlook 13
cricket1001 Problems with calendar syncing Using Outlook 0
P Syncing problems with add-ins Using Outlook 3
T problems with Contacts Using Outlook 8

Similar threads