实现效果
- 弹出对话框,输入收件人。
- 弹出对话框,输入收件人邮箱。
- 点击确认,发送邮件。
代码
-- 弹出对话框,输入收件人
set nameDialog to display dialog "请输入收件人:" default answer "luo" buttons {"确认"} default button 1
-- 保存收件人邮箱到recipientAddress
set recipientName to text returned of nameDialog
-- 弹出对话框,输入收件人邮箱地址
set addressDialog to display dialog "请输入收件人邮箱:" default answer "[email protected]" buttons {"确认"} default button 1
-- 保存收件人邮箱到recipientAddress
set recipientAddress to text returned of addressDialog
-- 设置邮件标题
set theSubject to "AppleScript Automated Email"
-- 设置邮件内容
set theContent to "This email was created and sent using AppleScript!"
-- 调用outlook
tell application "Microsoft Outlook"
-- 创建邮件
set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent}
-- 调用邮件
tell theMessage
set myemail to {name:recipientName, address:recipientAddress}
-- 设置邮件收件人信息
make new recipient with properties {email address:myemail}
-- 发送邮件
send
end tell
end tell
参考链接
- AppleScript的终极入门手册
- 《AppleScript权威指南》
- Complete list of AppleScript key codes