代码之家  ›  专栏  ›  技术社区  ›  Joseph Williamson

无法获取本地邮件。使用Apple脚本的应用程序帐户

  •  0
  • Joseph Williamson  · 技术社区  · 8 年前

    我正试图通过邮件中的id获取消息。应用程序使用Apple脚本。如果邮件仍在收件箱中,它可以工作,但是我在本地mac电脑上有帐户名为“on my mac”的邮件,每当我运行此脚本时,它会给我一个错误“Mail got a error:Cant get account”on my mac。号码:-1728。

    # THIS WORKS
    # set MessageID to 375586
    # set _mailBox to "INBOX"
    # set _account to "TheWilliamson"
    
    # THIS DOESN'T WORK
    set MessageID to 11351
    set _mailBox to "2001"
    set _account to "On My Mac"
    
    
    tell application "Mail"
    
        try
            set mybox to mailbox _mailBox of account _account
    
            # ERROR: Mail got an error: Can’t get account "On My Mac". Number: -1728
    
        on error eStr number eNum
            display dialog eStr & " Number: " & eNum buttons {"OK"} default button 1
            return
        end try
    end tell
    
    1 回复  |  直到 8 年前
        1
  •  0
  •   pbell    8 年前

    “在我的Mac上”的子“文件夹”不是帐户,而是邮箱。因此,您可以使用

    Set MyMailbox to mailbox of MyMessage --> string with name of the mailbox
    

    另外,不要混淆消息和消息ID。消息ID只是消息的一个属性。 仅供参考,简单地说,账户是你拥有的不同地址的电子邮件。