Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-13-2012, 02:20 PM
starrouter starrouter is offline Run Macro anytime new mail message form is opened Windows 7 64bit Run Macro anytime new mail message form is opened Office 2010 32bit
Novice
Run Macro anytime new mail message form is opened
 
Join Date: Aug 2012
Posts: 1
starrouter is on a distinguished road
Default Run Macro anytime new mail message form is opened

Is there any way to automatically run a macro every time I open the new mail message form ?
Please note that I mean the new mail message form that I open when I want to start a new
outgoing message, not opening a newly received message.



Thanks.
Reply With Quote
  #2  
Old 02-24-2013, 11:29 AM
niton niton is offline Run Macro anytime new mail message form is opened Windows 7 64bit Run Macro anytime new mail message form is opened Office 2010 64bit
Competent Performer
 
Join Date: Jul 2012
Posts: 102
niton is on a distinguished road
Default

http://msdn.microsoft.com/en-us/libr...ffice.12).aspx

Place this in the ThisOutlookSession module. Untested

Code:
Public WithEvents myOlInspectors As Outlook.Inspectors

Private Sub Application_Startup()
    Set myOlInspectors = Application.Inspectors
End Sub

Private Sub myOlInspectors_NewInspector(ByVal Inspector As outlook.Inspector)
     Dim msg as Mailitem

     If (Inspector.CurrentItem.Class = olMail) Then

	 Set msg = Inspector.CurrentItem

            If msg.Size = 0 Then
                MsgBox "Replace the message box with your code."
           End If
     End If
     Set msg = Nothing
End Sub

Last edited by niton; 02-24-2013 at 11:32 AM. Reason: Typo in "ThisOutlookSession"
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Weird message “the file ( ) should be opened as read-only unless changes to it need t Jamal NUMAN Word 6 11-13-2013 01:53 AM
Run Macro anytime new mail message form is opened Mail Merge error message rec Mail Merge 1 04-29-2011 10:30 PM
Editing default message form lvr123 Outlook 0 01-07-2011 05:33 AM
Do I need a Form or a Macro?? Keith24249 Excel 0 08-23-2010 06:23 AM
sent mail error message Carolemc Outlook 0 09-26-2006 03:21 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:08 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft