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.
Similar threads
Thread starter Title 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
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
J GoDaddy migrated to Office365 - Outlook Wont Add Account Exchange Server Administration 8
F Outlook 2019 Outlook 2019 Add and Sync to New computer Comcast server Using Outlook 2
witzker Add a text line at the end of the note field in all selected Contacts Outlook VBA and Custom Forms 7
A iCloud Outlook Add In is causing Outlook 2021 to crash and got disabled Using Outlook 4
N How to add or delete items to Move dropdown Menu Using Outlook 0
G Add contacts birthday to calendar Using Outlook 4
V How to add 'Previous Item' and 'Next Item' to the Quick Access Toolbar Using Outlook 1
Commodore Safe way to add or update holidays; Windows Notifications issue Using Outlook 8
kkqq1122 How would I add Search for attachment name Outlook VBA and Custom Forms 3
L did MS ever add way to text via Outlook Using Outlook 5
P How to add a column named categories when searching in Outlook Using Outlook 0
M add new attendee to existing meetings with VBA Outlook VBA and Custom Forms 5
N Can't create NEW GROUP and add/remove a member from existing Group in Outlook Using Outlook 1
witzker Outlook 2019 Pls. add a Prefix for OUTLOOK 2019 here Using Outlook 1
P Add inanimate objects to meetings? Using Outlook 1
O Outlook 2010 Add delete button to the side of the message list Using Outlook 1
BartH Add a string to the conditions in .Conditions.BodyOrSubject.Text Outlook VBA and Custom Forms 2
A "Get Add-Ins" - Which Version of Outlook to use Using Outlook 1
D Do I need Exchange Add-In? Using Outlook 6
C-S-R Manage Add-ins (Remove Wunderlist) Using Outlook 6
A iCloud add in problems Using Outlook 4
L Macro to add Date & Time etc to "drag to save" e-mails Outlook VBA and Custom Forms 17
C Looking for feedback on new Outlook Add-in Using Outlook 0
L isn't there an OL add-on that flags addressee before sending Using Outlook 3
S Add VBA save code Using Outlook 0
P Shortcut Pane - add shortcut to Office365 group mailbox Using Outlook 1
Z Add ComboBox Value to Body of Email Outlook VBA and Custom Forms 1
G How to add a folder shortcut to outlook quick access toolbar? Using Outlook 6
G Add to Outlook Contacts - Point to non-default contacts folder Using Outlook 0
M Automatically add senders first name to a greeting Outlook VBA and Custom Forms 1
C Add Form to Appointments Received, Automatically Outlook VBA and Custom Forms 6
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
Z 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

Similar threads

Top