Pages

Friday, July 01, 2011

Macro to check if your Outlook Outbox contains any items

 

Here is a macro for Outlook 2007/2010 that will check to see if your Outbox contains anything after Send/Receive completes.

1. Start Outlook
2. Click Tools->Macro->Visual Basic Editor…or press Alt+F11
3. If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
4. Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
5. Edit the code as needed. I included comment lines wherever something needs to or can change
6. Click the diskette icon on the toolbar to save the changes
7. Close the VB Editor
8. Click Tools > Trust Center
9. Click Macro Security
10. Set Macro Security to "Warnings for all macros"
11. Click OK
12. Close Outlook
13. Start Outlook. Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run. Say yes.

Macro is below

####

Dim WithEvents olkSync As Outlook.SyncObject

Private Sub olkSync_SyncEnd()
If Session.GetDefaultFolder(olFolderOutbox).Items.count > 0 Then
msgbox "A send/receive just completed and there are still unsent items in your Outbox.", vbExclamation + vbOKOnly, "Unsent Item Warning"
End If
End Sub

Private Sub Application_Quit()
Set olkSync = Nothing
End Sub

Private Sub Application_Startup()
Set olkSync = Application.Session.SyncObjects.Item(1)
End Sub
Source
http://www.experts-exchange.com/Software/Internet_Email/Email/Email_Clients/Q_25198625.html?sfQueryTermInfo=1+10+30+email+outbox+stuck
 

No comments: