简体   繁体   English

我可以设置AppleScript创建的电子邮件的编码吗?

[英]Can I set the encoding of an e-mail message created by AppleScript?

I have to send a mailing list and want to use Apple Mail for this. 我必须发送邮件列表,并想为此使用Apple Mail。 I have created a script that reads a UTF8 encoded text file and uses this text to set the contents of the e-mail message. 我创建了一个脚本,该脚本读取UTF8编码的文本文件,并使用该文本设置电子邮件的内容。 This text is in variable thisText. 该文本在变量thisText中。 The code importing the text is similar to 导入文本的代码类似于

set fileHandle to open for access theFile
set mailText to (read fileHandle) as «class utf8»
close access fileHandle

After this, I make small adjustments to the text for each recipient and prepare the e-mails with the following code: 在此之后,我对每个收件人的文本进行一些小的调整,并使用以下代码准备电子邮件:

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 <xxx@xxxxxxxx.com>"
    end tell
  end tell
end using terms from

The problem is that if the text contains special characters, Mail displays them incorrectly. 问题是,如果文本包含特殊字符,则Mail会错误地显示它们。 I believe that Mail doesn't understand that the encoding of the message is UTF8. 我相信Mail无法理解邮件的编码是UTF8。 Is there a way to define the encoding of a message when making it? 创建消息时,是否可以定义消息的编码? something like: 就像是:

properties {encoding:utf8}

perhaps? 也许? I tried this and it didn't work. 我试过了,但是没有用。 I was unable to find the answer elsewhere. 我在其他地方找不到答案。

我发现有关此功能是否有效的冲突信息,但是尝试使用以下终端命令更改默认邮件编码:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM