applescripting mailing a web page/newsletter

Hi, and happy new year to you all.

I’m trying to automate sending a monthly newsletter to clients, but I can’t get Mail to actually send it. Basically, I’ve used gui scripting to get Safari to open a web page and ‘press’ command and i. Then I’ve told Mail to Bcc to ‘Group 1’ and then keystroke return to set the addresses (and the process will repeat for all client groups in address book, but that’s where it falls over. The email is ready to send, but I can’t applescript the Send Mail (Command + Shift + D).

The script is basically as follows:

Tell application Safari
open location “http://www.domain.com
tell application “system events”
keystroke i using command down

– this opens the web page and ‘sends’ it to Mail

tell application “mail”
activate
tell application “system events”
keystroke tab
keystroke tab
keystroke “Group 1”
keystroke return

– Mail then tabs down to the bcc field and sets it to Group 1 of the mailing list –

And now I want to tell Mail to send the email, and then repeat the process for Groups 2 and 3, etc.

Any help with this (and refinement tips) most gratefully accepted.

Cheers,

Kev.

Hi all,

Nevermind. After a bit of trial and error, I got this to work:

tell application “Safari”
activate
open location “http://www.domain.co.uk
end tell
delay 5
tell application “System Events”
keystroke “i” using command down
delay 3
keystroke tab
delay 1
keystroke tab
delay 1
keystroke “Group 1”
delay 1
keystroke return
end tell
tell application “Mail”
activate
end tell
tell application “System Events”
keystroke “d” using {command down, shift down}
end tell

Does anyone know if a way of doing this without UI scripting?

Cheers,

kev.

HI again,

OK, so I’ve given up on not using UI scripting on this, and am quite content to keep it as it is However, I wonder if it’s possible to repeat the mailing process for a number of Address Book groups. The script above works fine for one group, but I’d really like to have several Address Book groups, and have the script repeat the mailing for each until the newsletter has been sent to all relevant groups.

Any help or pointers would be most gratefully received.

Cheers,

Kev.