Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Add-Ins / August 2006

Tip: Looking for answers? Try searching our database.

Selection Object of Outlook View Control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tanutatu@hotmail.com - 24 Aug 2006 11:07 GMT
Hi

We are using Outlook 2003 and above, VSTO and C# for developing an
Outlook add-in.

We are using the Outlook View Control to display messages from folders.

We wanted to process the items selected from outlook view control.For
the same we capture the "Selection_Change" event of the view control
and tried to access the "Selection" object in the event handler.

We did reach the event handler but we are not able get anything from
the "Selection" object.
i.e viewcontrol.Selection object has no appropriate properties exposed.

Can someone post a C#  code snippet for getting items selected from the
outlook view control OR
Give some links/pointers on how to go about it?

Thanks & Regards
TT
Josh Einstein - 26 Aug 2006 05:02 GMT
You need to reference the Outlook PIA. Then cast the selection property to
type Microsoft.Office.Interop.Outlook.Selection such as:

using Outlook = Microsoft.Office.Interop.Outlook;
....
Outlook.Selection currentSelection = viewCtl.Selection as Outlook.Selection;
if ( currentSelection != null && currentSelection.Count > 0 )
{
   Outlook.MailItem currentMailItem = currentSelection[0] as
Outlook.MailItem;
   if ( currentMailItem != null )
   {
       // you've got a selected mail item!
   }
}

Signature

Josh Einstein / Tablet PC MVP
Einstein Technologies, LLC
-----------------------------------------------------
Tablet Enhancements for Outlook 3.0 Now Available
Unleash the potential of Outlook on your Tablet PC, Origami, or UMPC.
Try it for 15 days - http://www.tabletoutlook.com/Go.ashx?id=ng

> Hi
>
[quoted text clipped - 17 lines]
> Thanks & Regards
> TT
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.