PC Review


Reply
Thread Tools Rate Thread

Add-in problem: Process All Marked Header doesn't display email bodies

 
 
TTT
Guest
Posts: n/a
 
      30th Mar 2010
My add-in is causing a minor problem with large files in Inbox.

I have Download Only Headers For Items Larger Than set to 10k. Any larger emails will display only their headers until I Mark To Download and Process All Marked Headers. This should cause the entire body to display, but with the add-in enabled they will not. I have to click onto another email then back, sometimes repeatedly.

The code that causes the problem is the same as in my previous Post

Add-in problem: First email in outbox gets stuck


It's where we are trying to add items to the context menu if the user has right clicked on an email.

if (_explorer.Selection[1] is Outlook.MailItem)

Touching the email seems to cause this problem, but I can't think of how to avoid this since these are the emails we want to change the menu for.

Is there no way to reset the Selection to its previous state?.
Submitted using http://www.outlookforums.com
 
Reply With Quote
 
 
 
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      30th Mar 2010
Only Outlook 2010 allows you to set/clear/add to Selection.

You are also assuming that if a context menu is displayed that it's for
whatever is selected, a logical fallacy. I would get the same response but
with a different context menu displayed if I right-clicked on a non-selected
item, a folder in the Navigation Pane, etc.

I could right-click on the second item in the view but have the first item
selected. You just can't tell.

Only starting with Outlook 2007 do you get to properly handle context menus
and know which is being displayed and what was right-clicked.

--
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


"TTT" <alistair[at]timetracer[dot]com[dot]au> wrote in message
news:%(E-Mail Removed)...
> My add-in is causing a minor problem with large files in Inbox.
>
> I have Download Only Headers For Items Larger Than set to 10k. Any larger
> emails will display only their headers until I Mark To Download and
> Process All Marked Headers. This should cause the entire body to display,
> but with the add-in enabled they will not. I have to click onto another
> email then back, sometimes repeatedly.
>
> The code that causes the problem is the same as in my previous Post
> Add-in problem: First email in outbox gets stuck
>
>
> It's where we are trying to add items to the context menu if the user has
> right clicked on an email.
> if (_explorer.Selection[1] is Outlook.MailItem)
> Touching the email seems to cause this problem, but I can't think of how
> to avoid this since these are the emails we want to change the menu for.
>
> Is there no way to reset the Selection to its previous state?. Submitted
> using http://www.outlookforums.com


 
Reply With Quote
 
TTT
Guest
Posts: n/a
 
      31st Mar 2010
I didn't explain that very well so I'll try again.

The cast to a MailItem changes the behaviour of the email that is selected (just like it changed them in the Outbox to not send in my previous question). I can't see any way to avoid "touching" the email, since that's what we want to display a new context menu for.

Is there any way to set the email back to an "untouched" state, or to get it to fill out its body correctly even if it has been "touched"?



>kenslovak wrote on Tue, 30 March 2010 09:08
>Only Outlook 2010 allows you to set/clear/add to Selection.


>You are also assuming that if a context menu is displayed that it's for
>whatever is selected, a logical fallacy. I would get the same response but
>with a different context menu displayed if I right-clicked on a non-selected
>item, a folder in the Navigation Pane, etc.


>I could right-click on the second item in the view but have the first item
>selected. You just can't tell.


>Only starting with Outlook 2007 do you get to properly handle context menus
>and know which is being displayed and what was right-clicked.


>--
>Ken Slovak
>[MVP - Outlook]

 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      31st Mar 2010
So try getting the item as an Object and using Reflection to get the Class
property or MessageClass property and examine the item type that way. See if
that causes the same problem as your cast.

--
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


"TTT" <alistair[at]timetracer[dot]com[dot]au> wrote in message
news:%(E-Mail Removed)...
>I didn't explain that very well so I'll try again.
> The cast to a MailItem changes the behaviour of the email that is selected
> (just like it changed them in the Outbox to not send in my previous
> question). I can't see any way to avoid "touching" the email, since that's
> what we want to display a new context menu for.
>
> Is there any way to set the email back to an "untouched" state, or to get
> it to fill out its body correctly even if it has been "touched"?


 
Reply With Quote
 
TTT
Guest
Posts: n/a
 
      1st Apr 2010
Fixed!

if (_explorer.Selection[1] is Outlook.MailItem)

becomes

bool isMailItem = false;

Object objectToInspect = _explorer.Selection[1];

Type type = objectToInspect.GetType();

try
{
if ((Outlook.OlObjectClass)type.InvokeMember("Class", System.Reflection.BindingFlags.GetProperty, null, objectToInspect, null) == Outlook.OlObjectClass.olMail)
{
isMailItem = true;
}
}
catch (Exception ex)
{
//eat
}

if (isMailItem)


Pretty obvious, really


Thanks a lot, Ken


>kenslovak wrote on Wed, 31 March 2010 09:05
>So try getting the item as an Object and using Reflection to get the Class
>property or MessageClass property and examine the item type that way. See if
>that causes the same problem as your cast.

 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      1st Apr 2010
Good.

I've found that sometimes casting will have odd effects but testing for
Class or MessageClass as you did before casting prevents the problems, as
you found.

--
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


"TTT" <alistair[at]timetracer[dot]com[dot]au> wrote in message
news:%(E-Mail Removed)...
> Fixed!
>
> if (_explorer.Selection[1] is Outlook.MailItem)
> becomes
>
> bool isMailItem = false;
>
> Object objectToInspect = _explorer.Selection[1];
>
> Type type = objectToInspect.GetType();
>
> try
> {
> if ((Outlook.OlObjectClass)type.InvokeMember("Class",
> System.Reflection.BindingFlags.GetProperty, null, objectToInspect, null)
> == Outlook.OlObjectClass.olMail)
> {
> isMailItem = true;
> }
> }
> catch (Exception ex)
> {
> //eat
> }
>
> if (isMailItem)
>
>
> Pretty obvious, really
>
>
> Thanks a lot, Ken


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook 2007 Retrieving Message Bodies for Marked Headers Llew Ralph Microsoft Outlook 0 1st Jan 2010 09:22 AM
Process Marked Header Disabled =?Utf-8?B?Y3JlYXRlX3NoYXJl?= Microsoft Outlook Discussion 3 7th Jan 2007 06:29 AM
Function Bodies in Header File =?Utf-8?B?R3JlZw==?= Microsoft VC .NET 1 22nd Jan 2006 01:48 AM
Process Marked Headers does not work for 1 email Zarny via OfficeKB.com Microsoft Outlook Discussion 0 12th Apr 2005 05:02 AM
OE doesn't show message bodies Jim Microsoft Outlook 1 27th Sep 2004 05:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:03 AM.