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



> >

>
 
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"?
 
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.
 
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
G Add Map It button to Custom Contacts Form in Outlook Outlook VBA and Custom Forms 1
G Outlook 2021 Add Picture to Custom Contact Form Outlook VBA and Custom Forms 2
P Can't add custom field to custom Outlook form, it always adds to the Folder instead Outlook VBA and Custom Forms 2
P VBA to add email address to Outlook 365 rule Outlook VBA and Custom Forms 0
S Outlook 2019 Custom outlook Add-in using Visual Studio Outlook VBA and Custom Forms 0
G automatically choosing "add to autocorrect" option Using Outlook 0
F Want to add second email to Outlook for business use Using Outlook 4
K Add an entry to a specific calendar Using Outlook 1
F Add a category before "Send an Email When You Add an Appointment to Your Calendar" Outlook VBA and Custom Forms 0
J Want to create a button on the nav bar (module add-in) to run code Outlook VBA and Custom Forms 2
M "Attachment Detacher for Outlook" add in, does it update the server copy of the email? Using Outlook 1
J Outlook 365 Add keywords from Listbox to the message body where cursor is placed Outlook VBA and Custom Forms 0
O Add Day Number of the year for 2023-2033 Outlook VBA and Custom Forms 5
J GoDaddy migrated to Office365 - Outlook Wont Add Account Exchange Server Administration 21
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 10
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

Similar threads

Back
Top