【问题标题】:Applescript to insert current date into subject line of email and the body of the email to be conditional depending on day sentApplescript 将当前日期插入电子邮件的主题行,电子邮件的正文取决于发送的日期
【发布时间】:2016-07-25 16:51:01
【问题描述】:

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

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

这可能吗?我尝试使用 Automator“创建新的 Outlook 邮件”,但无法在内部应用任何类型的条件,所以我认为原始 Applescript 是可行的方法。

【问题讨论】:

  • 是的,原始的 Applescript 是要走的路。我很惊讶您找不到有关如何 1. 获取今天的日期,2. 与目标日期进行比较,3. 在 Outlook 中创建具有给定主题和正文内容的新电子邮件的示例

标签: applescript automator


【解决方案1】:

是的,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

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

【讨论】:

  • 对不起 Jweaks,我错过了“Outlook”这个词。我刚刚更新了脚本,将“邮件”替换为“Microsoft Outlook”。语法几乎相同。主要区别在于添加收件人。
  • 我将它用于邮件 - 有什么区别?将“Microsoft Outlook”替换为“邮件”的唯一区别是什么?
  • 是的,将“邮件”替换为“Microsoft Outlook”,还有添加收件人的行:在邮件中,它是:在属性 {name:"" 的收件人末尾新建收件人, 地址:Mon_Destinataire}
猜你喜欢
  • 2016-11-23
  • 1970-01-01
  • 2021-06-22
  • 1970-01-01
  • 2018-10-29
  • 2013-11-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多