首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >outlook Mac AppleScript保存附件

outlook Mac AppleScript保存附件
EN

Stack Overflow用户
提问于 2016-12-19 13:24:13
回答 2查看 2.3K关注 0票数 0

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

我检查过这条路,看上去很好。

有什么想法吗?

EN

回答 2

Stack Overflow用户

发布于 2016-12-19 13:38:19

我无法看到您的所有代码(假设有超过这两行),所以我无法用您的场景来测试它。

然而,我发现很多论坛上的人都有同样的问题。

看看来自这个论坛的这段代码

代码语言:javascript
复制
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
票数 0
EN

Stack Overflow用户

发布于 2019-02-11 01:36:47

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

代码语言:javascript
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41223596

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档