Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Can't get existing message

Hi folks.

I'm trying to update a current email message that's new, to add the contents of my clipboard. The clipboard has a url. Essentially it's an "add current url to my email right here" script. This is what I have:

tell application "Safari" to set myLoc to the URL of document 1
set the clipboard to myLoc

tell application "Mail"
-- set the content of myM to (myContent + (the clipboard rule type string))
set myTarget to message of window 1 as outgoing message
set myStuff to the content of myTarget
tell myTarget
set content of myTarget to (myStuff & myLoc & return & return)
end tell
end tell

Any ideas what I'm doin wrong?

Thanks.

G5 1.8, Blackbook 2.0, Mac Pro 2.8 (8c), iMac 17 2.0, Touch2, Shuffle2, iPod40, Mac OS X (10.6.4), iPhone? Heck I'm still giggly about MultiFinder!

Posted on Nov 10, 2010 12:17 AM

Reply
5 replies

Nov 11, 2010 1:20 AM in response to BioRich

Any ideas what I'm doin wrong?


I don't actually know what you're doing wrong. May I suggest another approach? Try this:

*tell application "Safari" to set myLoc to the URL of document 1*
*set the clipboard to myLoc*
*tell application "Mail" to activate*
*tell application "System Events" to tell process "Mail"* -- [GUI Scripting|http://www.macosxautomation.com/applescript/uiscripting/index.html]
*key code 125 using command down* -- ⌘ down arrow
*keystroke return* -- paragraph break
*keystroke "v" using command down* -- ⌘V to paste the URL
*end tell*

Nov 11, 2010 8:41 AM in response to Pierre L.

Heh. For some reason I can't get a current outgoing message into an object. Most Mail.app scripts take focus of a new outgoing message like this:

*set myMail to (make new outgoing message with properties {content:"alpha"})*

If I can get that to work for a current outgoing message that isn't assigned to a variable, then I'm golden.

I like your approach. One thing though. It enters the text (rather quickly as well) after the signature. I am not familiar with this approach. Is there a way to hold the current location/focus?

Thanks for the post.

Nov 11, 2010 9:43 AM in response to BioRich

Heh. For some reason I can't get a current outgoing message into an object.

Neither can I. It seems impossible to get any property of an outgoing message. I don't know why.

Is there a way to hold the current location/focus?

I hadn't thought about the signature (which I rarely use myself). If you want to paste the URL at the insertion point, you could just remove the two following lines from the script:
*key code 125 using command down*
*keystroke return*

Is this the case in Outlook 2011 on the MAC

I know nothing about Outlook. Sorry, I can be of no help.

Nov 11, 2010 9:48 AM in response to Pierre L.

Haha...it worked!

Hey thanks very much. Here is the code:

*tell application "Safari" to set myLoc to the URL of document 1
set the clipboard to myLoc
tell application "Mail" to activate
tell application "System Events" to tell process "Mail" -- GUI Scripting
keystroke "v" using command down -- ⌘V to paste the URL
end tell*

No clue where that "Outlook 2011" comment came from. I use Mail.app.

Thanks again!

Cheers

Can't get existing message

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.