1

这里总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

1 回答 1

0

我不知道您过滤主题的标准是什么。

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

如果发生错误——例如主题中的字符数少于 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
于 2015-07-30T20:36:57.777 回答