2016-04-05 130 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

相關問題