AppleScript发送邮件

实现效果

  1. 弹出对话框,输入收件人。
  2. 弹出对话框,输入收件人邮箱。
  3. 点击确认,发送邮件。

代码

-- 弹出对话框,输入收件人
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 "luoxiaolei@duck.com" 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

参考链接

posted on 2022-12-11 11:49  Simle  阅读(175)  评论(0)    收藏  举报