View Full Version : How to use VBA to select (activate) a mailitem in the explorer like we use the mouse
Hi all,
I am a rookie for outlook VBA. I apologize if this question is too simple but it really bothers me for a long time. I even don't know how to search the answer from the dicussion history so I hope you are kind to give me this favor.
I know when we use find or restrict, we could get the mailitems that fit the criteria. But after that, it looks we could just display it or printout..., but could we not to do so but only select this mailitem in explorer just like we use mouse to click on a mailitem (not double click on it).
the real reason for this request is I always feel it is a good way to read mail but sorting by the subject when I select the latest mail of a specific mail subject. However, in my outlook, it often does sorting the mails by subject but lose to keep my original selected mail selected (usually the selected mail becomes a mail with blank subject). Does anyone experience this and have even better solution to my problem? Thanks for all you patience.
TonyJollans
12-03-2007, 04:26 AM
I'm not quite sure what you want.
When you click on an e-mail to select it, you make the choice based on what you see on the screen. How can VBA code make that decision as to which e-mail to select?
As for sorting - what should happen, and does for me, is that sorting does not change the selected e-mail - it should still be selected after the sort.
If you filter such that the selected e-mail is no longer visible, what should Outlook do - and what would you want any VBA code to do?
Hi Tony,
Thanks for the prompt and kind response.
My main demand is to sort mails by "subject".
I read mails from the latest arrived one.
When I see an unread mail comes, I select that mail by mouse and then click the subject to sort. Then I can see how many mails under this subject has been discussed and could go through the whole discussion in one time.
However, sometimes, when the sorting done, the selected mail changes to the blank subject so I can't find the actual mail grouping I want to read.
That's the motivation that I want to use VBA to locate the right mail grouping.
My thought is as below:
1. select the mail by mouse.
2. execute the program
3. program can make the sorting in explorer and find the mail subject that I select at step 1. And VBA could make this mail selected instead of display so I can see all mails under this subject in explorer.
Is it possible or any better idea? Thanks!
TonyJollans
12-03-2007, 06:04 AM
I'm not an Outlook expert but it seems to me that what you want is default behaviour that you should be getting anyway.
Do you have a lot of e-mails with blank subjects? I don't think it's normal. To even see if I could recreate the situation I had to artificially create one. Do you still have a problem if you don't have any such e-mails?
I can understand why you are frustrated by the behaviour but I don't think trying to write some code to reproduce it (even if i could) is the best solution. It would be better to find out what is happening and why.
Hi Tony,
I understand your point. However, it looks not quite regular :dunno(I admit I didn't try hard to clarify why and when this will happen due to I guess even I found the root cause, I may not be able to resolve it. For example, if it is an Outlook bug, though I don't know if any other person ever experience the same issue. Or it may due to some mails are with inappropriate subjects. However, I still can't restrict people to edit their mails). That's why I try to find a workaround. I admit I am not so engineer style in solving problems.:sleuth:
Excel could use activate or select to choose a cell. Does Outlook provide any similar control to choose a mailitem in an explorer but not have to display in an inspector? This question is still insteresting and worthy to find the answer?:ipray:
TonyJollans
12-03-2007, 12:06 PM
I've just had a little look at this but I'm afraid I can't see easily how to change the displayed order of mail items.
I will post back if I find out - or I find anything suggesting why you have the problem to begin with.
Sorry not to be more help. Maybe somebody else here knows something I don't.
Thanks anyway Tony.
Do you think another thought is more promising and attractive?
I am thinking dynamically generate a search folder (with the mail subject of the selected mailitem in explorer). I just afraid it will take too long to execute and also I still don't succeed to come out this search folder. I think also it will need to consider automatically delete the search folder when next search starts or always keep the same folder but change the search criteria. I am not familiar with all these objects and feel difficult to practice.
How about this idea below?
Is it possible to sort mails by subject first and then put the mail groups with unread mailitems at the beginning. If it is doable, then I could just read mail groups from top to bottom until there is no mail groups with unread mailitems.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.