tell application "Mail"
(* 電子メールアプリケーションのバージョン *)
set mailversion to version as string
(* 表示または送信の処理を指定 - displayForManualSend
が true ならば、ユーザが送信できるように、メッセージが
生成され、ウィンドウに表示されます。false の場合、
メッセージはすぐに送られます *)
set displayForManualSend to true
(* メッセージの一般的な要素を指定 *)
set bodyvar to return & return & "Test body."
set addrVar to "bogus@apple.com"
set addrNameVar to "Guinea Pig"
(* 添付書類を指定 *)
(* このファイルリストはその他の設定を示す *)
(* 電子メールを送信するためのスクリプト手順 *)
(* 注意:mailto 形式の URL では添付書類の *)
(* 指定ができない *)
set fileAttachThis to choose file of type "TEXT"
set fileList to {fileAttachThis}
(* 件名を定義 *)
set subjectvar to "Test Message From AppleScript with Attachment!"
(* メッセージを作成 *)
set composeMessage to (a reference to (make new compose message ¬
at beginning of compose messages))
tell composeMessage
make new to recipient at beginning of to recipients ¬
with properties {address:addrVar, display name:addrNameVar}
set the subject to subjectvar
set the content to bodyvar
tell content
repeat with aFile in fileList
make new text attachment ¬
with properties {file name:aFile} ¬
at before the first word of the ¬
first paragraph
end repeat
end tell
end tell
(* メッセージを送信または表示 *)
if displayForManualSend then
set messageEditor to make new message editor ¬
at beginning of message editors
(* 次に、電子メールアプリケーションのバージョン
1.0 と 1.1. にはあるが以降のバージョンで修正されたバグの
回避方法を示す *)
if mailversion is "1.0" or mailversion is "1.1" then
set compose message of last message editor to composeMessage
else
set compose message of first message editor to composeMessage
end if
else
send composeMessage
end if
end tell
|