Extract Contact Info from web form in body of emails

UPDATE.

The carriage return is fixed now and the script above updated. no need to do any changes.

Part of my job means I have lots of finder windows open on two screens And have to open the same windows everyday. They are windows to network shares which I monitor for new files.
I also had other people who needed the same networks and windows displayed.
Each window had its own place and size on the screens.
Tedious…

So I got into learning Applescript out of necessity. And wrote a script that mounted the volumes associated with the windows then open, size and position them.
That script was my first.
Normally you first is something like

display dialog "Hello World!" buttons {"OK"} default button 1

I have id and am still doing most of my learning by following this forum like this. And using it to pick at code and issues others have. I see if I can work them out for myself, much the same as I have done for you here.

I do have some books but have not used them much. So cannot really recommend them.

I suggest you read the official Apple Introduction to AppleScript overview

This will be a good starting point. And pick a simple task that you want to automate. It does not have to be something you will use in the real would but having a goal helps by stopping you going off on too many tangents and nothing to show for it.

You can also look at the Tutorials for Beginning Scripters over at the unScripted part of this site which has tons of tutorials and examples

Mark,
Thanks for the resources.
For some reason the script doesn’t work in outlook.
I tried it both as an application from the desktop and loaded it into the folder and ran it from the script library in outlook.
I have the email selected and then play the script, but it doesn’t do anything.
The other scripts are working - create a note or a task from the email.
I wonder does every line in the form have to be filled out?
Often people don’t fill out the entire form.
Sorry for all the trouble.

Thats very odd. It is working fine on my mac from the script menu.

1, Does the script work when run in Applescript Editor

2,
If you have not already enabled the Applescript Editor script menu for Applescripts.
Then open the Apple Script Editor’s preferences.
Check (tick) the Show Script menu in menu bar .

A new menu bar item will appear. Which will look like the script menu in Outlook.

Click the Script menu and Navigate to :Open Script folder->Open Users Script folder

Place the Script in the Users Script folder that opens up.
Now when you click the Script menu. You will see the script listed in the Script items.
Just select it and it will run.

Does it work from here.

No they do not.

Mark,
I did as you suggested and ran it both from the script menu and via the Apple Script editor.
In the editor this is what comes up:

Events:
tell application “Microsoft Outlook”
get selection
→ incoming message id 37557
get item 1 of incoming message id 37557
→ incoming message id 37557
get plain text content of incoming message id 37557
→ "sendtoemail: william@williammorrisstudio.com
name: Tootsie Roll
address: 1716 Ellie Ct
citytown: Benicia
statezip: CA 94510
mailfrom: tootsie@tootsieroll.com
telephone:
foundus: american bungalow
galleryname:
Lamp_1: Briggs
textareaName: Please type your message here.
submitButtonName: Submit

This e-mail was generated from a form submission on your website.

"
make new contact with properties {first name:“Tootsie”, last name:“Roll”, business street address:“1716 Ellie Ct”, business city:“Benicia”, business zip:“CA 94510”, email addresses:{{address:“tootsie@tootsieroll.com”, type:work}}, phone:“”, custom field one:“american bungalow”, company:“”, custom field two:“Briggs”, note:“”}
→ contact id 5540
end tell
Result:
contact id 5540 of application “Microsoft Outlook”

Replies:
tell application “Microsoft Outlook”
get selection
→ incoming message id 37557
get item 1 of incoming message id 37557
→ incoming message id 37557
get plain text content of incoming message id 37557
→ "sendtoemail: william@williammorrisstudio.com
name: Tootsie Roll
address: 1716 Ellie Ct
citytown: Benicia
statezip: CA 94510
mailfrom: tootsie@tootsieroll.com
telephone:
foundus: american bungalow
galleryname:
Lamp_1: Briggs
textareaName: Please type your message here.
submitButtonName: Submit

This e-mail was generated from a form submission on your website.

"
make new contact with properties {first name:“Tootsie”, last name:“Roll”, business street address:“1716 Ellie Ct”, business city:“Benicia”, business zip:“CA 94510”, email addresses:{{address:“tootsie@tootsieroll.com”, type:work}}, phone:“”, custom field one:“american bungalow”, company:“”, custom field two:“Briggs”, note:“”}
→ contact id 5540
end tell
Result:
contact id 5540 of application “Microsoft Outlook”

Result:
contact id 5540 of application “Microsoft Outlook”

So it looks like it’s working, but there is nothing that comes up or appears on the screen in outlook.
Should there be an interface that appears when the script is run?

Mark,
My apologies - I just ran a test email from my website and ran the script when the email came into outlook.
It does it’s thing in the background -
I just clicked on the mail from: email address and opened the contact page and all of the information is in there.

Really appreciate all of your efforts here and expertise.
Regards,
William

No problem. Partly my fault. I should have mentioned there will not be any indicator of progress.

My suggestion is you put one in. It is an easy thing to do and gives you that first little goal I spoke about.

Cheers.