0
我編寫了一個AppleScript來備份我的所有電子郵件。我已將大量電子郵件保存爲本地硬盤驅動器上的.eml文件,並將它們從服務器中刪除。有沒有辦法使用AppleScript加載.eml文件爲消息以獲得日期發送,主題等等?AppleScript - 獲取.eml文件的信息
我編寫了一個AppleScript來備份我的所有電子郵件。我已將大量電子郵件保存爲本地硬盤驅動器上的.eml文件,並將它們從服務器中刪除。有沒有辦法使用AppleScript加載.eml文件爲消息以獲得日期發送,主題等等?AppleScript - 獲取.eml文件的信息
怎麼是這樣的:
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
請確保您注意文件的編碼,如果您使用其他字符。
非常感謝。它對日期工作正常。但對於這個問題,有一個問題。我得到一個很長的字符串,最後有「Subject:=」和一長串隨機字母。我怎樣才能使它工作? –
這個腳本適用於我的測試文件,如果你想讓我處理更廣泛的電子郵件範圍,我可以看看它失敗的地方。只要做(做shell腳本「cat /test.eml | grep Subject:」),看看你給了什麼。 –