2016-04-05 133 views
0

我想完成Automator中的工作流程,剩下的唯一步骤是创建一个电子邮件,其内容取决于它建成的那一天。Applescript插入当前日期到电子邮件的主题行和电子邮件的正文取决于发送的日期

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

这可能吗?我试图使用Automator“创建新的Outlook邮件”,但无法应用任何种类的条件,所以我认为原始的Applescript是要走的路。

+0

是的,原始的Applescript是要走的路。我很惊讶,你找不到如何获得今天的日期的例子,2.比较你的目标日期,3.在Outlook中创建新的电子邮件与给定的主题和正文内容 – jweaks

回答

0

是的,AppleScript会更加灵活。在你的Automator流程,添加一个动作“运行AppleScript”和替换脚本:

on run {input, parameters} 
set My_Destinataire to "[email protected]" -- 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 

您必须调整“输入”的电子邮件地址通过,则必须调整主题/内容字符串中你需要什么工作日和周末。

+0

对不起Jweaks,我错过了“外表”。我刚刚更新了脚本,用“Microsoft Outlook”替换了“Mail”。语法几乎相同。主要区别是添加收件人。 – pbell

+0

我会用它来发送邮件 - 区别是什么?用'Mail'取代'Microsoft Outlook'是唯一的区别吗? –

+0

是的,将“Mail”替换为“Microsoft Outlook”,而且添加收件人的行:在Mail中,它是:在收件人的结尾处为具有属性的收件人创建新名称{name:“”,address:Mon_Destinataire} – pbell

相关问题