How to improve the email item selection event performance?


P

paresh

Hi,

I have noticed some issues with handling explorer change event when mailbox
is large. I have Outlook add-in which handles explorer change event like
below and displays senders name as a button caption which is created on
Outlook toolbar. It takes long sometimes to change the caption button.

Could you tell me how could I optimize the single email item selection event?

Thanks,
Paresh

My code:

Private WithEvents objExpl As Outlook.Explorer

Friend Sub InitHandler(olApp As Outlook.Application, strProgID As String)
Set objExpl = objOutlook.ActiveExplorer 'Explorer Object
End Sub

Private Sub objExpl_SelectionChange()
If objExpl.Selection.Count > 0 Then
For Each objMailItem In objExpl.Selection
If objMailItem.Class = olMail Then
msgbox "email item";
End If
Next
End If
End Sub
 
Ad

Advertisements

M

Michael Bauer [MVP - Outlook]

If you want to handle one item only, there's no need to loop through all the
collection. Instead, just work with Selection(1).

But I suppose what takes long is accessing the commandbar button, and that's
the code we don't see. If it's always the same button, keep its reference,
so you don't need to find it again and again.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Sun, 11 Oct 2009 01:54:01 -0700 schrieb paresh:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top