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 

Copy Text from Outlook Email to Specified Cells in Excel

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



Joined: 15 Jul 2008
Posts: 1

PostPosted: Tue Jul 15, 2008 7:03 pm    Post subject: Copy Text from Outlook Email to Specified Cells in Excel Reply with quote

I am trying to develop a script that copies specific text from emails I receive in a set format. However, I am a AHK newbie....so some guidance would be appreciated. The emails come in from a sendmail form and look something like this (there is more info of course):

------
Name - John Doe
Emp (No) - 20302022
J&B - Tall
------

I'd like to copy JUST the data (John Doe, 20302022, Tall) into an Excel worksheet (already created) in the (next available) empty row into the appropriate columns. So I have an excel file that has already been formatted I just want it to copy the form info into the correct columns in the next available row.

I started by having AHK recognize the window for outlook based on the inbox name (which means it's already open and set to the inbox). Then I used MouseClick and ClickDrag to highlight the text. I realize these are based on fixed positions and may cause some trouble down the line (should I resize the different viewing panes, etc.).

Any input on how to approach this? Specifically - how can I have the data copied? How do I get AHK to recognize an email msg with a specific title? Can I create a loop to go through multiple e-mails with the same title and input the data into excel in subsequent rows? How do I get excel to copy data into specific rows/columns?

Thanks for your help!!

-A

p.s. Moderators, please delete the duplicate msg posted by guest. I thought I was logged in. My mistake.
Back to top
View user's profile Send private message
vixay



Joined: 12 Jun 2008
Posts: 51

PostPosted: Fri Aug 01, 2008 8:34 am    Post subject: Options Reply with quote

You can use Excel/Outlook VBA as well to do this.

Basic psuedocode:

Select all text in message
Parse text, retain only right hand tokens after the "-"

Switch to excel
Find last blank cell in range
Paste values

As for ahk, you could copy the text (use Home and END + Ctrl C to copy all). i.e. use keyboard shortcuts versus mouse movements to ensure it works always.

and search & replace new lines with TAB
and search & replace all record delimiters with newline

and paste in excel, it will automatically get put in different columns then.

If you post a full email and your excel file might be easier to work out the code.
Back to top
View user's profile Send private message
bourney1kenobi



Joined: 22 Feb 2009
Posts: 4

PostPosted: Sun Feb 22, 2009 10:22 am    Post subject: Need to copy variable text from email body to clipboard Reply with quote

Hey,

I can't see that this one ever got answered but I have a similar problem that I've now spent HOURS looking for a solution to....

Maybe this is staring me in the face, but my knowledge of scripting at this point would fit on a the back of a postage stamp!

Basically, I have an automatically generated plain text email that contains the recipient's email address in the message body between two brackets ,eg (your.name@company.com) which I need to find, cut out, delete the remaining empty brackets, and then tab back to the 'To' field, and paste the extracted email address.

I'm afraid my ability to search within an active window for a text variable between two constant symbols is not there yet.....but I'm sure somebody knows how to do it?

Here's hoping......
Thanks in advance!
Back to top
View user's profile Send private message
vixay



Joined: 12 Jun 2008
Posts: 51

PostPosted: Mon Feb 23, 2009 6:54 am    Post subject: Sample Reply with quote

Please provide sample Input, with Desired Output
Back to top
View user's profile Send private message
bourney1kenobi



Joined: 22 Feb 2009
Posts: 4

PostPosted: Mon Feb 23, 2009 12:36 pm    Post subject: Sample of text for cutting email address from Message Body Reply with quote

Hi

I'm working along the lines of: -

1. Highlight (without opening) an email in the Outlook Inbox.

LControl & RControl::
Send, {ALTDOWN}w{ALTUP}{TAB 3}{SHIFTDOWN}{DOWN 8}{SHIFTUP}{DEL} ; This removes the Outlook forwarding text (Date, etc.) from the top of the message

...now I need to insert some script to find the first round bracket '('....then...

{SHIFTDOWN}scroll forward, selecting all text until it finds the closing bracket ')' {SHIFTUP}{CTRLDOWN}x{CTRLUP}
{BACKSPACE}{DEL} ; To delete the brackets that remain (if they do!)

Then tab back up to the 'To' field and paste in the text from the clipboard....

{SHIFTDOWN}{TAB 3}{SHIFTUP}{CTRLDOWN}v{CTRLUP}
return

....plus I'd also add {DEL} entries to delete the brackets from the 'To' field if they were cut as part of the required syntax.

Thanks again in advance for any help!
Back to top
View user's profile Send private message
vixay



Joined: 12 Jun 2008
Posts: 51

PostPosted: Tue Feb 24, 2009 12:32 pm    Post subject: Reply with quote

If you know regex, try this

http://www.autohotkey.com/docs/commands/RegExMatch.htm

you can use this tool to help you create the appropriate regex

http://www.gskinner.com/RegExr/

try this topic as well to extract text

http://www.autohotkey.com/forum/topic35597.html

search the forums, text manipulation is a common question, and with a bit of diligence i'm sure you'll get there, you've made good progress.

post your script in code blocks to make it easier to read and copy/paste... so that i can try what you have written
Back to top
View user's profile Send private message
bourney1kenobi



Joined: 22 Feb 2009
Posts: 4

PostPosted: Thu Feb 26, 2009 8:01 pm    Post subject: RegEx string to find email addresses Reply with quote

Thanks again for the response vixay. I have to say that I think my problem is that I just can't interpret the examples posted for RegEx usage. Following your response though, I have at least found another site (http://www.regular-expressions.info/) that has posted the RegEx string syntax to find email addresses, which is: -

\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b

...so I feel that we're getting there, slowly.

Unfortunately I don't know how to use this with RegEx. I'm going to persevere with my searches, but if anybody can point me in the right direction in the meantime then that would be teriffic!
Back to top
View user's profile Send private message
bourney1kenobi



Joined: 22 Feb 2009
Posts: 4

PostPosted: Thu Feb 26, 2009 8:02 pm    Post subject: posting code blocks Reply with quote

Oh yeah, how do I post my script in "code blocks"?

cheers
Back to top
View user's profile Send private message
vixay



Joined: 12 Jun 2008
Posts: 51

PostPosted: Fri Feb 27, 2009 4:10 am    Post subject: Reply with quote

Hit the "code" button when you compose your message to start a block, hit again to end, or type text as below.
[code]Your Text Here[/code]

You should also provide your sample input so that i can test any solutions i come up with
Back to top
View user's profile Send private message
Sushma
Guest





PostPosted: Thu Sep 15, 2011 7:49 am    Post subject: Copy Text from Outlook Email to Specified Cells in Excel Reply with quote

I regularly get mails which are in paragraph and i need to paste it to specified template format in excel. so how can i do it easily and can i get code to copy the complete mail and paste it in excel which directly gets converted to required template format.

Any help for this query..
Back to top
vixay



Joined: 12 Jun 2008
Posts: 51

PostPosted: Thu Sep 22, 2011 4:56 pm    Post subject: Re: Sample Reply with quote

vixay wrote:
Please provide sample Input, with Desired Output

^^
Back to top
View user's profile Send private message
Display posts from previous:   
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