Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
Business Applications
Tag Cloud
access audio black screen blue screen boot bsod connection crash dell desktop driver drivers dvd email error excel firefox hard drive hardware hijackthis internet keyboard laptop malware monitor network networking outlook problem processor recovery registry cleaner router safe mode screen slow sound spyware trojan upgrade vba video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Business Applications >
Outlook 2003 running Macro when closing emails

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

Closed Thread
 
Thread Tools
3d0's Avatar
3d0 3d0 is offline
Junior Member with 1 posts.
 
Join Date: Sep 2009
09-Sep-2009, 12:01 PM #1
Question Outlook 2003 running Macro when closing emails
Hi im new to using outlook but i do have some programing experience, what i want to do is that whenever i close an email message i want this macro to run, but i dont know how to do this, and if that is possible, is there a way to make this macro run only on the first time i read the mail?

please help

I'm trying to use WithEvents to get the closing mailItem event to trigger my macro, i found this code off the internet for getting the mailitem but i cant seem to get it to work, help plzzz

Dim WithEvents vInspectors As Outlook.Inspectors
Dim WithEvents vExplorers As Outlook.Explorers
Dim WithEvents vExplorer As Outlook.Explorer
Dim WithEvents vMailItem As Outlook.MailItem

'I use the following code to get the vMailItem variable set:
Private Sub Class_Initialize()
Set vInspectors = Application.Inspectors
Set vExplorers = Application.Explorers
If Not ActiveExplorer Is Nothing Then
Set vExplorer = ActiveExplorer
If TypeName(vExplorer.Selection.Item(1)) = "MailItem" Then
Set vMailItem = vExplorer.Selection.Item(1)
End If
End If
End Sub
Private Sub Class_Terminate()
Set vInspectors = Nothing
Set vExplorer = Nothing
Set vExplorers = Nothing
Set vMailItem = Nothing
End Sub
Private Sub vExplorer_SelectionChange()
If vExplorer.Selection.Count = 1 And TypeName(vExplorer.Selection.Item(1)) = _
"MailItem" Then Set vMailItem = vExplorer.Selection.Item(1)
End Sub
Private Sub vExplorers_NewExplorer(ByVal Explorer As Explorer)
Set vExplorer = Explorer
If TypeName(vExplorer.Selection.Item(1)) = "MailItem" Then
Set vMailItem = vExplorer.Selection.Item(1)
End If
End Sub
Private Sub vInspectors_NewInspector(ByVal Inspector As Inspector)
If TypeName(Inspector.CurrentItem) = "MailItem" Then
Set vMailItem = Inspector.CurrentItem
End If
End Sub

'and then after this i guess i use

Private Sub vMailItem_Close()

' my codes for the macro

end sub

Is that right??

Last edited by 3d0 : 09-Sep-2009 03:32 PM.
Closed Thread Bookmark and Share

Tags
email, event handler, macros, outlook

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Smart Search

Find your solution!



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.

Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 07:58 AM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.