AppleScript - 获取 .eml 文件的信息

发布于 2024-12-10 03:01:14 字数 154 浏览 4 评论 0原文

我编写了一个 AppleScript 来备份我的所有电子邮件。很多电子邮件我已经在本地硬盘上保存为 .eml 文件,并从服务器中删除了它们。有没有办法使用 AppleScript 作为消息加载 .eml 文件,以获取其中的发送日期主题等?

I write an AppleScript to backup all my emails. A lot of emails I have already saved as .eml files on my local hard drive and deleted them from the server. Is there a way to load the .eml files with AppleScript as message to get the date sent, subject etc. of them?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

策马西风 2024-12-17 03:01:15

像这样的事情怎么样:

set fromField to text 7 thru -1 of (do shell script "cat /test.eml | grep From:")
set dateField to text 7 thru -1 of (do shell script "cat test.eml | grep Date:")
set toField to text 5 thru -1 of (do shell script "cat /test.eml | grep To:")
set subjectField to text 10 thru -1 of (do shell script "cat /test.eml | grep Subject:")

正文有点难,因为您需要决定是否只需要电子邮件正文或还需要嵌入到正文中的所有以前的电子邮件。以下内容获取我的测试电子邮件的正文。

set temp to do shell script "cat /test.eml"
set text item delimiters to "--"

set temp2 to (text item 3 of temp)
set text item delimiters to "
"
set messageField to paragraphs 6 thru -1 of temp2 as text

如果您使用其他字符,请务必注意文件的编码。

How about something like this :

set fromField to text 7 thru -1 of (do shell script "cat /test.eml | grep From:")
set dateField to text 7 thru -1 of (do shell script "cat test.eml | grep Date:")
set toField to text 5 thru -1 of (do shell script "cat /test.eml | grep To:")
set subjectField to text 10 thru -1 of (do shell script "cat /test.eml | grep Subject:")

The body is a little harder since you need to decide if you only want the emails body or also all the previous emails that are embedded into the body. The following gets the body of my test email.

set temp to do shell script "cat /test.eml"
set text item delimiters to "--"

set temp2 to (text item 3 of temp)
set text item delimiters to "
"
set messageField to paragraphs 6 thru -1 of temp2 as text

Make sure you watch out for the encoding of the file if you use other characters.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文