email - 如何通过applescript和邮件规则从邮件下载附件?

标签 email applescript macos-sierra

我通过电子邮件自动收到很多电子名片,我想将它们自动导入到我的联系人中。

我编写了一个 AppleScript,它将打开 vcard 文件并导入联系人。但首先我需要下载文件,对吗?

但是如何使用 AppleScript 和邮件中的规则从电子邮件下载附件文件?

谢谢。

干杯, 克里斯

最佳答案

下面的脚本将所选电子邮件中附加的文件保存到目标文件夹中。然后您可以使用这些文件将它们添加到地址簿中。

set Dest to ((path to desktop folder) as string) & "FMail:" -- the folder to save attached files
tell application "Mail"
activate
set ListMessage to selection -- take all emails selected
repeat with aMessage in ListMessage -- loop through each message
    set AList to every mail attachment of aMessage
    repeat with aFile in AList --loop through each files attached to an email
        if (downloaded of aFile) then -- check if file is already downloaded
            set Filepath to Dest & (name of aFile)
            save aFile in Filepath as native format
        end if
    end repeat -- next file
end repeat -- next message
end tell

我添加了很多评论以使其清楚。然后您就可以根据您的需要进行调整。

关于email - 如何通过applescript和邮件规则从邮件下载附件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39882312/

相关文章:

applescript - 如何通过 AppleScript 或其他脚本语言获取 Dropbox 共享链接 URL?

macos-sierra - Mac OS Sierra上的Gitx:不再支持Objective-C垃圾收集

python - 升级 Python 包 dateutil : Could not find a version

javascript - Google Apps 脚本 | Switch Case 仅选择默认选项

php - mail() - 电子邮件有效但短信无效

codeigniter - 当我使用 codeigniter 电子邮件类发送电子邮件时显示 html 源的电子邮件

cocoa - 在 MAC OSx 上将 FLV 转换为 MP4 视频文件

javascript - 使用 Apple Remote 播放/暂停 Soundcloud 选项卡的脚本