Re: Unable to add attachment to mail message in Leopard via Applescript
Re: Unable to add attachment to mail message in Leopard via Applescript
- Subject: Re: Unable to add attachment to mail message in Leopard via Applescript
- From: Ron <email@hidden>
- Date: Mon, 26 Nov 2007 03:03:19 -0600
Here's the code I use and it's still working in 10.5 and 10.5.1
Ron
set cma_content_pull_in_excel_format to {"Macintosh
HD:Users:rwk:Desktop:cma_content_pull_" & currentdate & "_" &
current_time & ".xls"} as string
<-- snip -->
set file_attachment to cma_content_pull_in_excel_format as alias
<-- snip -->
tell application "Mail"
set theBody to {""} as text
set newMessage to make new outgoing message with properties
{subject:emailsubject & currentdate, content:theBody & return & return}
tell newMessage
set visible to true
set sender to senderemailad
make to recipients with properties {address:personsemailad}
make cc recipients with properties {address:personsemailad_cc}
try
make new attachment with properties {file name:file_attachment} at
after the last word of the last paragraph
set message_attachment to 0
log "message_attachment = " & message_attachment
on error
set message_attachment to 1
end try
end tell
if message_attachment = 0 then
set visible of newMessage to true
send newMessage
end if
end tell
On Nov 26, 2007, at 12:42 AM, applescript-users-
email@hidden wrote:
----------------------------------------------------------------------
Message: 4
Date: Sun, 25 Nov 2007 21:58:19 -0800
From: Arshad Tayyeb <email@hidden>
Subject: Unable to add attachment to mail message in Leopard via
Applescript
To: email@hidden
Message-ID: <email@hidden>
Content-Type: text/plain; charset="us-ascii"
I'm trying to use applescript to attach a file to an email message
(ultimate goal is to use osascript to attach files to an email via the
command line). However, in Leopard, the following fails to attach
anything to the message. Any idea what I'm doing wrong? It seems
like it should work.
tell application "Mail"
set theMessage to make new outgoing message
tell content of theMessage
make new attachment with properties {file
name:"Affogato:Klack:src:foo.c"} at after last paragraph
end tell
end tell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.apple.com/mailman/private/applescript-users/attachments/20071125/639dbad0/attachment.html
------------------------------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden