代码之家  ›  专栏  ›  技术社区  ›  Gary Harrison

使用AppleScript通过Outlook for Mac发送电子邮件已不再有效

  •  0
  • Gary Harrison  · 技术社区  · 6 年前

    我有一个AppleScript,它读取一个包含地址列表的文本文件,然后在Outlook中为每个地址创建一条带有主题的消息,并自动发送电子邮件。在过去一年左右的时间里,它一直在工作,但它不再像预期的那样工作。我不确定这是Outlook的最新更新还是我的Mac OS的问题。现在的情况是,它只会发送txt文件第1行的地址。

    结果窗口中的错误消息是:

    error "Can’t get every to recipient of missing value." number -1728 from every «class trcp» of missing value
    

    在事件窗口中:

    tell application "Microsoft Outlook"
        read "/Users/******/OneDrive/address.txt" as «class utf8»
    end tell
    tell current application
        read "/Users/******/OneDrive/address.txt" as «class utf8»
    end tell
    tell application "Microsoft Outlook"
        set the clipboard to "abuse@*****"
        make new outgoing message with properties {subject:"this is a test"}
        make new recipient with properties {email address:{address:"abuse@****"}} at end of every to recipient of outgoing message id 465175
        send outgoing message id 465175
        set the clipboard to "postmaster@*****"
        make new outgoing message with properties {subject:"this is a test"}
    Result:
    error "Can’t get every to recipient of missing value." number -1728 from every «class trcp» of missing value
    

    在“回复”窗口中:

    tell application "Microsoft Outlook"
        read "/Users/******/OneDrive/address.txt" as «class utf8»
            --> error number -10004
    end tell
    tell current application
        read "/Users/******/OneDrive/address.txt" as «class utf8»
            --> "abuse@****
    postmaster@****"
    end tell
    tell application "Microsoft Outlook"
        set the clipboard to "abuse@*****"
        make new outgoing message with properties {subject:"this is a test"}
            --> outgoing message id 465175
        make new recipient with properties {email address:{address:"abuse@****"}} at end of every to recipient of outgoing message id 465175
            --> to recipient 1 of outgoing message id 465175
        send outgoing message id 465175
        set the clipboard to "postmaster@*****"
        make new outgoing message with properties {subject:"this is a test"}
            --> missing value
    Result:
    error "Can’t get every to recipient of missing value." number -1728 from every «class trcp» of missing value
    

    我在查看Outlook的AppleScript库时注意到,我找不到收件人的参考资料。我也尝试过从网上其他来源获得的代码,这些代码被报告为直接在代码中使用一个地址进行工作和测试,但我仍然收到一个类似的错误“缺少值”

    我的Outlook是16.39版(20071300) 我的MacOS是10.15.5版

    这是脚本,为了隐私,我在mac电脑上标出了用户名; 告诉应用程序“Microsoft Outlook”

    set srcFile to ("/Users/******/OneDrive/address.txt") as text
    
    set lns to paragraphs of (read srcFile as «class utf8»)
    repeat with ln in lns
        set the clipboard to ln
        set theMessage to make new outgoing message with properties {subject:"this is a test"}
        make new recipient with properties {email address:{address:ln}} at end of to recipients of theMessage
        send theMessage
    end repeat
    

    结束语

    有人能帮忙吗?

    0 回复  |  直到 6 年前
        1
  •  0
  •   Armin Deeg    6 年前

    我可以确认我的发送邮件错误已通过Outlook 16.41(20072700)Insider Fast Release修复

        2
  •  0
  •   Armin Deeg    6 年前

    嗨,自从office更新16.39以来,我也遇到了类似的问题,以前的office版本16.38运行良好。

    如果outlook mac关闭,此脚本只能运行一次。在第二次尝试而不再次关闭outlook后,会产生一个错误:

    tell application "Microsoft Outlook"
        set theMessage to make new outgoing message with properties {sender:{name:"My Name", address:"demo@demo.com"}, subject:"test", plain text content:"Hallo"}
        
        tell theMessage
            make new to recipient with properties {email address:{address:"test@test.com"}}
        end tell
        send theMessage
    end tell
    

    Ergebnis: 错误“缺少与Nachricht–make–nicht对应的值。”数字-1708,来自缺失值

    翻译为:“缺少的值不理解 制作 “信息”或 “缺少值无法理解 制作 事件“