There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Tag Cloud
access acer asus bios bsod computer crash desktop dns driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop malware memory modem monitor motherboard network printer problem ram registry repair router security slow software sound toshiba trojan usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Business Applications >
Outlook 2003 running Macro when closing emails

Reply  
Thread Tools
3d0's Avatar
3d0 3d0 is offline
Junior Member with 1 posts.
 
Join Date: Sep 2009
09-Sep-2009, 01: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 at 04:32 PM..
Reply

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.

Search Tech Support Guy

Find the solution to your
computer problem!




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



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 03:13 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.