outlook Mac AppleScript保存附件

时间:2016-12-19 13:24:14

标签: macos outlook applescript email-attachments

我正在使用 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.

我检查了路径,看起来很好。

有什么想法吗?

2 个答案:

答案 0 :(得分:0)

我看不到你的所有代码(假设有超过这两行),所以我无法用你的方案测试它。
但是,我能够找到很多人都有相同问题的论坛。

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

答案 1 :(得分:0)

这是一个有效的示例,包括处理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
相关问题