Applescript将当前日期插入电子邮件的主题行,并根据发送的日期将电子邮件正文作为条件

时间:2016-04-05 16:05:40

标签: applescript automator

我正在尝试完成Automator中的工作流程,剩下的唯一步骤就是创建一封电子邮件,其中的内容取决于其构建的日期。

Outlook电子邮件的主题需要包含当前日期,并且电子邮件的正文需要if语句来检查今天是星期一还是星期五,以允许电子邮件说出" ...本周"或者" ...即将到来的一周"。

这可能吗?我尝试使用Automator"创建新的Outlook邮件消息"但是无法在里面应用任何条件,所以我认为原始的Applescript是要走的路。

1 个答案:

答案 0 :(得分:0)

是的,AppleScript会更灵活。在您的Automator流程中,添加一个操作“运行Applescript”并将脚本替换为:

on run {input, parameters}
set My_Destinataire to "myfriend@gmail.com" -- assign here the email address

set Wday to first word of date string of (current date) -- get the days of the week in local language
if Wday is in {"Saturday", "Sunday"} then -- fill subject and content for week end
set My_Subject to "we are " & Wday & " !"
set My_Content to "this email is for next upcoming week…"
else -- fill subject and content with message for working days
set My_Subject to "we are " & Wday & ", an other working day !"
set My_Content to "this email is for current week…"
end if

tell application "Microsoft Outlook" -- creation of the new email itself
activate
set NewMessage to make new outgoing message with properties {subject:My_Subject, content:My_Content}
make new recipient at NewMessage with properties {email address:{name:"", address:My_Destinataire}}
send newMessage -- if you want to send the message directly without checking it
end tell
return input
end run

您必须进行调整以传入“输入”电子邮件地址,并且必须将主题/内容字符串调整为工作日和工作日所需的字符串。

相关问题