Outlook.Selection: determine what type of item is selected.

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Aug 2008
Posts: 169
Reputation: murderotica is an unknown quantity at this point 
Solved Threads: 2
murderotica's Avatar
murderotica murderotica is offline Offline
Junior Poster

Outlook.Selection: determine what type of item is selected.

 
0
  #1
Nov 26th, 2008
Hello there, I've been doing some research about the Outlook.Selection interface and made an application out of it. My goal is to get all of the items in my inbox folder. I have already created a way to get all of them, my problem is to filter each types of items in my inbox. I found a link that could handle it but it is written in VB. It has all of the information that I needed but it seems that I can't get the MessageClass of the variable which is of type Object. Here is the link: http://support.microsoft.com/kb/240935

This is exactly what I want my filtering to be in C#. Any thoughts and suggestions I would really appreciate. Thank you.
Last edited by murderotica; Nov 26th, 2008 at 1:13 am.
An Avalanche In D Minor
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Outlook.Selection: determine what type of item is selected.

 
0
  #2
Nov 26th, 2008
Accessing mails from outlooks inbox is generally quite simple and mine seems to pick up the differences. What code do you have as while I didnt derrive mine from that vb, mine uses pretty much the same concept.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 169
Reputation: murderotica is an unknown quantity at this point 
Solved Threads: 2
murderotica's Avatar
murderotica murderotica is offline Offline
Junior Poster

Re: Outlook.Selection: determine what type of item is selected.

 
0
  #3
Nov 26th, 2008
Thanks for the reply. I'm using VSTO Sir. My only problem right now is to filter the items that I'm dragging (whether it is a MailItem, MeetingItem, AppointmenItem etc.). The sample code in the link uses MessageClass which he got from the variable of type Object which contains the item selected in the ActiveExplorer. I think C# has a different way of getting the MessageClass which is I'm not that really familiar.
An Avalanche In D Minor
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Outlook.Selection: determine what type of item is selected.

 
0
  #4
Nov 26th, 2008
Frirstly, Im not male. Please do not make such rash assumptions.

Secondly, Ive asked for some code as it would seem you've approached it very differently from me as all items correctly report their code for me, and perhaps you're going about it the wrong way.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 169
Reputation: murderotica is an unknown quantity at this point 
Solved Threads: 2
murderotica's Avatar
murderotica murderotica is offline Offline
Junior Poster

Re: Outlook.Selection: determine what type of item is selected.

 
0
  #5
Nov 26th, 2008
I'm so sorry, I didn't mean it. This is my test program seperated from my application.

  1. private void Form1_Load(object sender, EventArgs e)
  2. {
  3. Outlook.Application app = new Outlook.Application();
  4. Outlook.NameSpace nmspc = app.GetNamespace("mapi");
  5. Outlook.MAPIFolder inbox = nmspc.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
  6.  
  7.  
  8. Outlook.MeetingItem item;
  9. for (int i = 8; i < 9; i++)
  10. {
  11. item = (Outlook.MeetingItem)inbox.Items[i];
  12. item.SaveAs(@"c:\TempFile\Temp" + item.EntryID.ToString() + ".msg", Outlook.OlSaveAsType.olMSG);
  13. MessageBox.Show(item.EntryID.ToString());
  14. }
  15.  
  16. }

This is just a test sample because I don't want to mess the whole application that I made. This is my way of getting all the items in my inbox. All I need is a filtering to determine if it is a MailItem, ApplicationItem, MeetingItem etc.
Last edited by murderotica; Nov 26th, 2008 at 10:44 pm.
An Avalanche In D Minor
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Outlook.Selection: determine what type of item is selected.

 
0
  #6
Nov 27th, 2008
OK, but that will pick up only meeting items, as you cant assign mail items to a meetingitem, it will cause an exception. the messageclass property is text and will confirm then which subtype of the item you picked is, such as out of office etc.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 169
Reputation: murderotica is an unknown quantity at this point 
Solved Threads: 2
murderotica's Avatar
murderotica murderotica is offline Offline
Junior Poster

Re: Outlook.Selection: determine what type of item is selected.

 
0
  #7
Nov 27th, 2008
I agree that MessageClass property will confirm which subtype is picked but I'm having a problem how to use it in C#.
An Avalanche In D Minor
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Outlook.Selection: determine what type of item is selected.

 
0
  #8
Nov 27th, 2008
Its a string, it will give you in words the type.

PS - just like in the vb example you posted
Last edited by LizR; Nov 27th, 2008 at 4:10 am.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 169
Reputation: murderotica is an unknown quantity at this point 
Solved Threads: 2
murderotica's Avatar
murderotica murderotica is offline Offline
Junior Poster

Re: Outlook.Selection: determine what type of item is selected.

 
0
  #9
Nov 27th, 2008
The line
  1. strMessageClass = oItem.MessageClass
seems does not work in C#. oItem is of type Object. It throws an error.
An Avalanche In D Minor
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Outlook.Selection: determine what type of item is selected.

 
0
  #10
Nov 27th, 2008
In your code above, "Outlook.MeetingItem item" as long as you called item.MessageClass you would be ok.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC