Applescript提取主题行

Applescript to extract subject line

一共n00b,绝对不是程序员。希望获得有关 applescript 的帮助。我基本上是在尝试从收件箱下方特定文件夹中的电子邮件中提取主题行。我需要它来提取主题行、查找一些数字(例如 123456)并提取最后 4 位数字。然后将其放入文本文件中。以下是我到目前为止所拥有的,但它不起作用。我根本没有得到任何输出。任何指导将不胜感激!

tell application "Microsoft Outlook"
    set theAccount to exchange account “my account"
    set topFolder to folder "Inbox"
    set subFolder to folder “Stuff"
    set theMessages to messages of subFolder
    set folderPath to ((path to home folder from user domain as string) & “emails")
    repeat with aMessage in theMessages
        my SetSubject(subject of aMessage)
    end repeat
end tell



on SetSubject(theSubject)
    tell application "Microsoft Outlook"
        try
            save theSubject in ((path to home folder from user domain as string) & “emails" & “numbers.txt" as string)
        end try
    end tell
end SetSubject
end

我不知道你筛选主题的标准是什么。

此示例将指定邮箱中邮件的所有主题的最后 4 个字符写入 home folder 文件夹 emails 中的文件 numbers.txt,一个主题每行。

如果发生错误——例如主题中的字符数少于 4——文件将可靠地关闭并且脚本将中止。

set numbersFile to (path to home folder as text) & "emails:numbers.txt"

tell application "Microsoft Outlook"
    set theSubjects to subject of messages of folder "Stuff" of folder "Inbox" of exchange account "my account"
end tell

try
    set fileDescriptor to open for access file numbersFile with write permission
    repeat with aSubject in theSubjects
        write (text -4 thru -1 of aSubject & return) to fileDescriptor starting at eof
    end repeat
    close access fileDescriptor
on error
    try
        close access file numbersFile
    end try
end try