Jump to content
Macro Express Forums

Thinktank request: Seeing the tree for the forest with controls.


Recommended Posts

Simple problem: Outlook mail reading window has a header with fields such as From, Sent, Subject and so on and I want to get the date and subject into a string var.


Difficulties: Since the fields I want can not be predetermined I have to define control vars with the index method. A varying number of controls means the index number varies. The Control Class changes as well.


Challenge: How would you approach the problem?


My thinking so far: Create a loop that will incrementally evaluate each control by incrementing the index number. When it finds one that is of the type “Static” it can grab the control text and if it equals “Sent:” I know the next index number is N+1. Also I know the class will be “RichEdit20WPT” so I can do a Get Control using the Run Macro in Variable and get my date sent field.


I ran into a technical problem that is probably unrelated so while I run that down I thought I would see if anyone has a better idea since this one is a little convoluted. Thanks!

Link to comment
Share on other sites



If I understand correctly, I would suggest a low-tech solution. Have the macro open the message into a separate window. Highlight the message and press <Enter> should do it.


Once the window is open, press Tab once to move to the From field. Another Tab moves to the Date field where you can grab the information. Tab through the To and CC fields to the Subject and grab that information. I can't think of any other fields that would be inserted to mess with the Tab order. But maybe that's what you're running into, so you're looking at Controls instead.


The above works for Outlook 2007. Shift Tab works with Outlook 2000. This starts at the bottom with the subject. Shift Tab in 2007 will not work if there are file attachments. The focus first goes to the attachment in 2007.

Link to comment
Share on other sites

Thanks for the input.


The macro only works once the email is open so that's no issue since the user needs to see the message body to make a decision.


Tabbing in a way has the same problem in that there are a varying number of fields. Finding the date could be done by grabbing each tab result and finding the first one with two slashes in it but there's no reliable test I can think of for the subject field since the user could type just about anything or nothing. Also tabbing thru will not stop at the labels so I can't predict what's happening.


I got to working on this for a while this morning and was making headway but you got me to thinking and I believe I have a better way. I will simply open up the email properties (ALT+f+i) and in there the controls will be consistent. I could also use the Internet Headers but I'd have to parse them. I wish I knew VBA...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...