我有一个 AppleScript 应用程序,它可以创建一封电子邮件(在 Mail.app 中),其中包含我通过对话框选择的选项中的附件。文本模板存储在.rtf
格式,以便非程序员可以根据自己的意愿更改文本模板。
我可以从以下地址创建电子邮件.txt
纯文本文件,但是当我导入.rtf
它导入格式化命令,我不希望在邮件中出现这些命令。
这是一个例子.rtf
导入到电子邮件中:
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360
{\fonttbl\f0\fswiss\fcharset0 Helvetica-Light;}
{\colortbl;\red255\green255\blue255;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
\f0\fs24 \cf0 英语使用者的技术邮件\
这是我的脚本的一部分:
-- Import the .rtf file and store content in the mycontent variable
set mycontent to (read "/Users/kiara/Desktop/mailer/technology/tech-en-content.rtf")
…
…
-- create mail from values stored in variables
tell application "Mail"
set theMessage to make new outgoing message with properties {visible:true, subject:mysubject, content:mycontent}
tell content of theMessage
make new attachment with properties {file name:this_file} at after last paragraph
end tell
end tell
是否可以导入格式化文本.rtf
文件到新邮件而不带格式代码(我选择 rtf 因为大多数粗体和颜色用于格式化文本)?
这是另一种方法:
set the clipboard to (read "/Users/kiara/Desktop/mailer/technology/tech-en-content.rtf" as «class RTF »)
tell application "Mail"
activate
set theMessage to make new outgoing message with properties {visible:true, subject:"mysubject"}
end tell
tell application "System Events"
tell process "Mail"
repeat until focused of UI element 1 of scroll area 4 of window 1
keystroke tab
end repeat
keystroke "v" using command down
end tell
end tell
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)