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

Status
Not open for further replies.
T

TTT

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?.
 
K

Ken Slovak - [MVP - Outlook]

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.

"TTT" <alistair[at]timetracer[dot]com[dot]au> wrote in message

news:%233PXHe9zKHA.3572@TK2MSFTNGP02.phx.gbl...
> 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 https://forums.slipstick.com
 
T

TTT

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.



> >

>
 
K

Ken Slovak - [MVP - Outlook]

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.

"TTT" <alistair[at]timetracer[dot]com[dot]au> wrote in message

news:%23EZhiWG0KHA.4136@TK2MSFTNGP05.phx.gbl...
> 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"?
 
T

TTT

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

Ken Slovak - [MVP - Outlook]

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.

"TTT" <alistair[at]timetracer[dot]com[dot]au> wrote in message

news:%232GDJrV0KHA.5512@TK2MSFTNGP06.phx.gbl...
> 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
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
T Problem with .Recipients.Add("alias") Outlook VBA and Custom Forms 3
C problem of add replicate of ex2k public folder to ex07 Exchange Server Administration 4
B add address from outlook 2007 contacts to word document problem Using Outlook 12
S Add DAG problem Exchange Server Administration 3
S add new mail user problem Exchange Server Administration 6
P Outlook problem with Add-in Using Outlook 1
T Add-in problem: First email in outbox gets stuck Outlook VBA and Custom Forms 7
B Add-in deployment problem Outlook VBA and Custom Forms 3
P Problem in permanent type add-in toolbar Outlook VBA and Custom Forms 6
K Re: Problem wit deploying Outlook Add-in Outlook VBA and Custom Forms 1
E Problem wit deploying Outlook Add-in Outlook VBA and Custom Forms 3
E Problem with Deploying Add-In Outlook VBA and Custom Forms 1
Y Outlook 2007 add-in installation problem on Vista Outlook VBA and Custom Forms 1
O Outlook tasks - Add text column with multiple lines Using Outlook 3
W April 2020 Office 365 Update - Add-Ons fail after Office 365 Update Using Outlook 6
B Task Filter Not Working When I add too many criteria Using Outlook 0
D Add date next to day name in Outlook Today calendar view Using Outlook 1
D iCloud Add-in not working in Outlook 2013 and Outlook 2016 After Windows Upgrade & iCloud Upgrade Using Outlook 2
P Add Paste Unformatted to QAT Using Outlook 1
M Ignore slow add-ins Using Outlook 0
B Add Prefix text to Subject Line Using Outlook 1
Jennifer Murphy Add birthdays to calendar Using Outlook 7
Z Add text to auto-forwarded e-mail Outlook VBA and Custom Forms 4
P Add, remove, & reorder folder pane Using Outlook 6
L Tired of Outlook disabling Adobe PDF Creator add-in Using Outlook 1
R Add 'Company' to Select Names Form Using Outlook 1
A Outlook 2016 Web add-in missing on some machines Using Outlook 9
P Syncing problems with add-ins Using Outlook 3
Mark Foley Cannot enable add-in in outlook 2010 Using Outlook 0
BretAB Is it possible to add a lookup field to a Message form? Outlook VBA and Custom Forms 4
J Add an Attachment Using an Array and Match first 17 Letters to Matching Template .oft to Send eMail Outlook VBA and Custom Forms 2
iwshim outlook 2013 - I cannot see the "Manage Add-ins" Using Outlook 2
A Add multiple servers "on behalf of" email to "safe senders" list. Using Outlook 1
S Add Exchange Account as Secondary to Existing PST? Exchange Server Administration 1
C Macro to add multiple recipients to message Outlook VBA and Custom Forms 3
A Add to Outlook Contacts from email - default view Outlook VBA and Custom Forms 1
P Add a contact to the New Task in Outlook 2016 Using Outlook 2
e_a_g_l_e_p_i Is there a way to add something that is in the "Format Text" tab to the "basic Text" on the message tab Using Outlook 1
B When working on emails in a certain folder, when I hit reply or reply all, I would like it re always reply all and add an email address to send to Outlook VBA and Custom Forms 3
M Macro to add date/time stamp to subject Outlook VBA and Custom Forms 4
O Outlook on Android - add BCC Using Outlook 2
J Execute Add-In Button from VBA Outlook 2016 Outlook VBA and Custom Forms 1
S Example VBA Macro - To Conditionally Change the From Account and Add a BCC Address on Emails Outlook VBA and Custom Forms 11
B When I add more search strings to RULES, it is not processing them Using Outlook 3
D Add Tetxbox at form open Outlook VBA and Custom Forms 1
Andrew Quirl Open attachment, manipulate without add-on program? Outlook VBA and Custom Forms 5
B Searching for a Add-In Using Outlook 3
J Add Fillable Fields to Existing Template Outlook VBA and Custom Forms 1
J vb to c# for Outlook add-in. Using Outlook 0
S Send email via SMTP - use transport rules to add to senders inbox (then rule to move to sent items Exchange Server Administration 1
Similar threads


















































Top