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

Applescript将当前日期插入电子邮件的主题行,电子邮件正文将根据发送日期设置条件,applescript,automator,Applescript,Automator,我正在尝试在Automator中完成一个工作流,剩下的唯一一步就是创建一封电子邮件,它的内容取决于它生成的日期 Outlook电子邮件的主题需要包含当前日期,电子邮件正文需要一个if语句来检查今天是星期一还是星期五,以便电子邮件可以说“…当前一周”或“…未来一周” 这可能吗?我尝试使用自动程序“创建新的Outlook邮件”,但无法在内部应用任何类型的条件,因此我认为使用原始Applescript是可行的 是的,AppleScript将更加灵活。在自动机流中,添加操作“运行Applescript”

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

Outlook电子邮件的主题需要包含当前日期,电子邮件正文需要一个if语句来检查今天是星期一还是星期五,以便电子邮件可以说“…当前一周”或“…未来一周”


这可能吗?我尝试使用自动程序“创建新的Outlook邮件”,但无法在内部应用任何类型的条件,因此我认为使用原始Applescript是可行的

是的,AppleScript将更加灵活。在自动机流中,添加操作“运行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

您必须调整以传入“输入”电子邮件地址,并且必须调整主题/内容字符串以满足工作日和周末的需要。

是的,原始Applescript是一种方法。我很惊讶你找不到关于如何1的例子。得到今天的日期,2。与你的目标日期相比,3。在Outlook中创建具有给定主题和正文内容的新电子邮件抱歉,我错过了“Outlook”一词。我刚刚更新了脚本,将“邮件”替换为“Microsoft Outlook”。合成税几乎是一样的。主要区别是添加收件人。我会将其用于邮件-区别是什么?将“Microsoft Outlook”替换为“Mail”是唯一的区别吗?是的,将“Mail”替换为“Microsoft Outlook”,但添加收件人的行:在Mail中,它是:在结尾处对收件人进行新建,对具有属性的收件人{name:,address:Mon_Destinataire}