A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

On click event for mail item selection



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old December 10th 08, 04:01 AM posted to microsoft.public.outlook.program_vba
Mark
external usenet poster
 
Posts: 238
Default On click event for mail item selection

I have a mail folder called MyInfo when I click on a mail item inside that
folder I want to execute vba code to go and grab details from a SQL Server
Database,
My problem is I cant find an "OnClick" event when a mail item is mouse clicked
Can any one help!
  #2  
Old December 10th 08, 02:48 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default On click event for mail item selection

When you click on an item in a folder it changes the selection. You can use
the Explorer.SelectionChange() event for what you want.

Instantiate an Explorer object declared WithEvents to handle the
SelectionChange() event and instantiate that Explorer object as the
ActiveExplorer.

When that event fires you can get the Explorer.Selection collection, which
can be iterated to handle all selected items. If there's only 1 selected
item then Selection.Item(1) will get that item in the event handler.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Mark" wrote in message
...
I have a mail folder called MyInfo when I click on a mail item inside that
folder I want to execute vba code to go and grab details from a SQL Server
Database,
My problem is I cant find an "OnClick" event when a mail item is mouse
clicked
Can any one help!


  #3  
Old December 10th 08, 09:47 PM posted to microsoft.public.outlook.program_vba
Mark
external usenet poster
 
Posts: 238
Default On click event for mail item selection

Im don't know how to perform the following:

"Instantiate an Explorer object declared WithEvents to handle the
SelectionChange() event and instantiate that Explorer object as the
ActiveExplorer."

Do you have an example!
__________________________________________________ _____________
"Ken Slovak - [MVP - Outlook]" wrote:

When you click on an item in a folder it changes the selection. You can use
the Explorer.SelectionChange() event for what you want.

Instantiate an Explorer object declared WithEvents to handle the
SelectionChange() event and instantiate that Explorer object as the
ActiveExplorer.

When that event fires you can get the Explorer.Selection collection, which
can be iterated to handle all selected items. If there's only 1 selected
item then Selection.Item(1) will get that item in the event handler.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Mark" wrote in message
...
I have a mail folder called MyInfo when I click on a mail item inside that
folder I want to execute vba code to go and grab details from a SQL Server
Database,
My problem is I cant find an "OnClick" event when a mail item is mouse
clicked
Can any one help!



  #4  
Old December 11th 08, 02:14 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default On click event for mail item selection

You can put the code in the ThisOutlookSession class and use something like
this:

Dim WithEvents oExpl As Outlook.Explorer

Private Sub Application_Startup()
Set oExpl = Application.ActiveExplorer
End Sub

Private Sub oExpl_SelectionChange()
Dim colSelection As Outlook.Selection
Dim obj As Object
Dim oMail As Outlook.MailItem

Set colSelection = oExpl.Selection
For Each obj In colSelection
If obj.Class = olMail Then
Set oMail = obj
' is a selected mail item do whatever with it
End If
Next
End Sub

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Mark" wrote in message
...
Im don't know how to perform the following:

"Instantiate an Explorer object declared WithEvents to handle the
SelectionChange() event and instantiate that Explorer object as the
ActiveExplorer."

Do you have an example!


  #5  
Old December 15th 08, 02:31 AM posted to microsoft.public.outlook.program_vba
Mark
external usenet poster
 
Posts: 238
Default On click event for mail item selection

Thankyou Ken, Once again I appreciate your help
All is no working well

"Ken Slovak - [MVP - Outlook]" wrote:

You can put the code in the ThisOutlookSession class and use something like
this:

Dim WithEvents oExpl As Outlook.Explorer

Private Sub Application_Startup()
Set oExpl = Application.ActiveExplorer
End Sub

Private Sub oExpl_SelectionChange()
Dim colSelection As Outlook.Selection
Dim obj As Object
Dim oMail As Outlook.MailItem

Set colSelection = oExpl.Selection
For Each obj In colSelection
If obj.Class = olMail Then
Set oMail = obj
' is a selected mail item do whatever with it
End If
Next
End Sub

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Mark" wrote in message
...
Im don't know how to perform the following:

"Instantiate an Explorer object declared WithEvents to handle the
SelectionChange() event and instantiate that Explorer object as the
ActiveExplorer."

Do you have an example!



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove Mail Item Event Doesn't Fire Nenad Add-ins for Outlook 3 November 8th 08 05:58 AM
New Mail Item Event Neetu Add-ins for Outlook 6 April 4th 08 02:11 PM
How to track the right click on the mail item??? Laxman Add-ins for Outlook 0 July 3rd 06 10:36 AM
double click mail item jpspringall Outlook and VBA 2 May 31st 06 10:18 AM
Trigger event on explorer right click (unselected item)? james Add-ins for Outlook 5 February 22nd 06 09:12 PM


All times are GMT +1. The time now is 12:25 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.