【问题标题】:outlook Mac AppleScript to save attachmentsOutlook Mac AppleScript 保存附件
【发布时间】:2017-05-04 13:32:27
【问题描述】:

我正在使用 Outlook for Mac 15.30(161251)

我有一个将所有附件保存到文件夹的脚本。它最近停止工作,我正在尝试找出原因。

旧的保存命令save theAttachment in file savePath

Microsoft Outlook got an error: An error has occurred.

我改成save theAttachment in POSIX file savePath

现在我收到了Microsoft Outlook got an error: Parameter error.

我已经检查了路径,它似乎很好。

有什么想法吗?

【问题讨论】:

    标签: macos outlook applescript email-attachments


    【解决方案1】:

    我看不到您的所有代码(假设不止这两行),因此我无法使用您的方案对其进行测试。
    但是,我能够找到很多有相同问题的人的论坛。

    看看this forum的这段代码:

    set saveToFolder to (choose folder with prompt "Choose the destination folder") as string
    set prefix to the text returned of (display dialog "Enter the text to prefix the saved attachment names with" default answer "" buttons {"Cancel", "OK"} default button 2)
    set ctr to 0
    
    tell application "Microsoft Outlook"
        set topFolder to mail folder "inbox" of on my computer
        set srcFolder to mail folder "myfolder" of topFolder
        set destFolder to folder "myFolder2" of topFolder
    
        set selectedMessages to messages of srcFolder
        repeat with msg in selectedMessages
            set ctr to ctr + 1
            set attFiles to attachments of msg
            repeat with f in attFiles
                set attName to (get the name of f)
                log attName
                set saveAsName to saveToFolder & prefix & ctr & attName
                log saveAsName
                save f in saveAsName
            end repeat
            move msg to destFolder
        end repeat
    end tell
    display dialog "" & ctr & " messages were processed" buttons {"OK"} default button 1
    return ctr
    

    【讨论】:

    • 您好,感谢您的建议...我试过了 - 但收到错误“查找程序​​出错:无法获取 POSIX 文件”~/outlooktempdowloadfolder....”
    • 为我的特定用途编辑了该脚本,但我仍然遇到相同的错误 - 我认为这是 Outlook 问题,而不是我的错误编码..
    【解决方案2】:

    这是一个工作示例,包括处理 posix 路径:

    set saveToFolder to POSIX path of (choose folder with prompt "Choose the destination folder")
    set ctr to 0
    tell application "Microsoft Outlook"
        set srcFolder to mail folder "SomeFolder" of on my computer
        set selectedMessages to messages of srcFolder
            repeat with msg in selectedMessages
    
                set sentstamp to time sent of msg
    
                set y to year of sentstamp
                set m to month of sentstamp
                set d to day of sentstamp
                set rdate to y & "-" & m & "-" & d
                set ctr to ctr + 1
    
                set attFiles to attachments of msg
                set actr to 0
                repeat with f in attFiles
                    set attName to (get the name of f)
                    log attName
                    set saveAsName to saveToFolder & "mrp-" & rdate & "-" & actr & ".csv"
    
                    set actr to actr + 1
    
                    save f in POSIX file saveAsName
                end repeat
            end repeat
    end tell
    
    display dialog "" & ctr & " messages were processed" buttons {"OK"} default button 1
    return ctr
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-02
      • 1970-01-01
      • 2015-05-22
      • 2017-08-28
      • 1970-01-01
      • 1970-01-01
      • 2016-09-01
      • 2016-05-28
      相关资源
      最近更新 更多