AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Grabbing info from an email

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
jonathan2260



Joined: 13 May 2008
Posts: 7

PostPosted: Sun May 18, 2008 3:29 pm    Post subject: Grabbing info from an email Reply with quote

Hello

I"m trying to grab information from emails to put them in variables.

Under this link, http://www.autohotkey.com/forum/viewtopic.php?t=31783
someone pointed out to me which commands could be useful to get the information without resorting to mouse positions.

My script works fine for mouse positions for myself but as soon as I tried to give it to a work colleague for him to try, it would not work because his outlook screen positions are different from mine.

I'm trying to figure it out but I'm not a programmer and I'm feeling lost trying to understand these commands so help would be greatly appreciated.

Basically I get work forms in an email format and I'm sending them into a ticket system using autohotkey.

Here's what it looks like a bit (edited to avoid conflict with employer)

Incident ID: xxxxxxxxxx
Store Number: xxxxx
Site ID: xxxxx
Contact Name: xxxxx
Open Time xx/xx/xx xx:xx:xx
Opened By: xxxxxx


How would I get it to grab the information (where it's all x in this example) in a way to make sure positions don't matter.

Is there any examples I can follow or can someone supply me with one with details of what the commands do?

Thanks for the help.
Back to top
View user's profile Send private message
n-l-i-d
Guest





PostPosted: Sun May 18, 2008 3:59 pm    Post subject: Reply with quote

You cannot address specific Outlook "windows" with the Control commands of AutoHotkey, and since focussing by click and using the clipboard is unreliable and a bit clumsy, to do it properly you would need to use COM.

Take a look at MS Office Automation Functions (via COM) [thanks Sean]

In this posting you can find a link to VBA code that might help.

HTH
Back to top
keybored



Joined: 18 Jun 2006
Posts: 90
Location: Phoenix, AZ

PostPosted: Sun May 18, 2008 4:27 pm    Post subject: meet grabby (well part of him) Reply with quote

jonathan,
Just so happens I am working on the same problem.

The code below works for non HTML emails if they contains CWP or UID (my work sends emails with this Universal ID etc...). I loop through the possible controls and update my variable when I hit a match. I am changing this to use StringLen to be more universal but I don't have Outlook at home so I have to finish later.

Code:
if (v_WinClass = "rctrl_renwnd32") ; if outlook active
{
   var1 = 1
   Loop, 6
   {
      ControlGetText, v_EmailData, RichEdit20W%var1%, A
         if v_EmailData Contains CWP,UID
         {
            v_GrabbedData = %v_EmailData%
            break
         }
      var1 := (var1 + 1)
   }
}
msgbox, %v_GrabbedData%
Back to top
View user's profile Send private message
ahklerner



Joined: 26 Jun 2006
Posts: 1206
Location: USA

PostPosted: Sun May 18, 2008 4:36 pm    Post subject: Reply with quote

I just started some MS Office automation functions.....they can be found Here
I just added Outlook_GetMessageText()..... You could use that combined with RegExMatch to get the info you need..... You may also want to see my post here....It shows how to automate Internet Explorer via COM, so that you will be able to make your script robust.
_________________
Back to top
View user's profile Send private message
keybored



Joined: 18 Jun 2006
Posts: 90
Location: Phoenix, AZ

PostPosted: Sun May 18, 2008 4:46 pm    Post subject: many thanks Reply with quote

ahklerner, It occurs to me he didn't say he has Outlook.

I will dig into your functions. I am making a tool for aggregating lots of emailed data we receive at work.
Back to top
View user's profile Send private message
ahklerner



Joined: 26 Jun 2006
Posts: 1206
Location: USA

PostPosted: Sun May 18, 2008 5:04 pm    Post subject: Re: Grabbing info from an email Reply with quote

jonathan2260 wrote:
...because his outlook screen...

_________________
Back to top
View user's profile Send private message
keybored



Joined: 18 Jun 2006
Posts: 90
Location: Phoenix, AZ

PostPosted: Sun May 18, 2008 5:51 pm    Post subject: that outlook Reply with quote

Yep that's a good sign

Tried your code remotely logged in from work. It is a limitation that the window has to be open. My code works either way, which was a happy surprise really, because I didn't plan for it. Of course it may break if something in the environment changes.

Anyway thanks for the help I will be using those tools for sure.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group