2013-05-15 32 views
0

我必須發送一個郵件列表,並希望爲此使用Apple Mail。我創建了一個腳本,用於讀取UTF8編碼的文本文件,並使用此文本設置電子郵件的內容。此文本在變量thisText中。導入文本的代碼類似於我可以設置由AppleScript創建的電子郵件的編碼嗎?

在此之後,我做小的調整,以文本爲每個收件人,並用下面的代碼編寫電子郵件:

using terms from application "Mail" 
    tell application "Mail" 
    set theAccount to "Economy-x-Talk Support" 
    set theNewMessage to make new outgoing message with properties ¬ 
     {account:theAccount, subject:thisSubject, content:thisText, visible:false} 
    tell theNewMessage 
     make new to recipient at end with properties {address:thisEmail} 
     set sender to "Economy-x-Talk Support <[email protected]>" 
    end tell 
    end tell 
end using terms from 

的問題是,如果文本包含特殊字符,則郵件將不正確地顯示它們。我相信郵件不明白郵件的編碼是UTF8。有沒有辦法在製作時定義信息的編碼?例如:

properties {encoding:utf8} 

也許?我試過這個,但沒有奏效。我無法在別處找到答案。

回答

3

我發現了衝突的這是否不工作的信息,但嘗試用下面的命令終端改變默認的郵件編碼:

defaults write com.apple.mail NSPreferredMailCharset "UTF-8" 
+0

如果我把在年初做一個shell腳本命令我的腳本,我必須在腳本末尾放置什麼來恢復默認情況?那會是「MacRoman」嗎? – Mark

+1

在腳本的開頭,執行'set oldEncoding to defaults read com.apple.mail NSPreferredMailCharset'。然後在最後:''默認寫入com.apple.mail「&space&oldEncoding' –

相關問題