【问题标题】:How to add the current month in AppleScript?如何在 AppleScript 中添加当前月份?
【发布时间】:2020-09-27 21:48:51
【问题描述】:

我有一个用于自动化小型工作流程的脚本,但我无法让主题列出当前月份。

这是我的脚本:

tell application "Finder" to set selectedItem to item 1 of (get selection)
set theAttachment to selectedItem as alias
set fileName to name of selectedItem

tell application "Microsoft Outlook"
    set newMessage to make new outgoing message with properties {subject:"(current month) as string Message from John Doe"}
    tell newMessage
        make new attachment with properties {file:theAttachment}
    end tell
    open newMessage
    get newMessage
end tell

这可能吗?我已经尝试过在线搜索和在 Script Debugger 中进行搜索,但我一直没能找到。提前致谢。

【问题讨论】:

    标签: macos outlook applescript


    【解决方案1】:

    我不使用 Microsoft Outlook,因此我将假设您的脚本执行时没有错误,但只会产生不希望的结果,即一封新的外发电子邮件,其中包含单词 "(current month) 作为字符串来自 John Doe 的消息” 在主题行中。

    在此基础上,要让您的主题行仅包含当前月份,请在脚本中找到包含以下内容的相关行:

    {subject:"(current month) as string Message from John Doe"}
    

    用这个替换它

    {subject:(current date)'s month as text}
    

    如果您希望主题行在月份之后包含其他文本,就像您的原始脚本一样,那么您可以将其替换为:

    {subject:((current date)'s month as text) & " Message from John Doe"}
    

    【讨论】:

    • 非常感谢。你最懂我心!我会更具体地讨论未来。 :)
    猜你喜欢
    • 2018-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多