使用 Applescript 呈现包含 HTML 内容的字符串的 HTML 视图,并在网页/Outlook 中将其显示为 HTML
此 applescript 获取电子邮件的 HTML 内容并将其存储在字符串中,然后再次将 html 内容粘贴到 webpage.html
中。但是,当我打开 webpage.html
时,它会将所有 HTML 标记显示为文本而不是 HTML 视图。
set mytext to string
tell application "Microsoft Outlook"
set the_messages to selection
repeat with this_message in the_messages
set mytext to content of this_message
end repeat
end tell
tell application "TextEdit"
activate
make new document
set text of document 1 to mytext as text
save document 1 in "/Users/mymac/Desktop/webpage.html"
end tell
这里的问题是,它将整个 HTML 作为纯文本粘贴到 webpage.html
中。因此,内容现在与所有标签一起显示。如何使用 Applescript 使网页以 HTML 格式显示。
编辑:
这是在 Outlook 的阅读窗格中呈现的 视图邮件窗口进行修改后。
set mytext to string
set hello to "hello this is testing"
set outputText to string
--get the content of a outlook message
tell application "Microsoft Outlook"
set the_messages to selection
repeat with this_message in the_messages
--set mytext to content of this_message
set mytext to source of this_message
end repeat
--adding some text to the content of the message
set mytext to mytext & hello
end tell
--pasting the content to a html file
tell application "TextEdit"
activate
make new document
set text of document 1 to mytext as text
--set source of document 1 to mytext as text
save document 1 in "/Users/mymac/Desktop/webpage.html"
end tell
--reading the contents from the html file
set theFile to "/Users/mymac/Desktop/webpage.html"
open for access theFile
set fileContents to (read theFile)
close access theFile
--pasting the modified contents to the outlook email
tell application "Microsoft Outlook"
set the_messages to selection
repeat with this_message in the_messages
set content of this_message to fileContents --modified email
--set fileContents to source of this_message(this does not modify the source of the message in view pane,Remains intact the original source)
end repeat
end tell
问题:
即使在进行修改后,如何查看发送给用户的电子邮件?
This applescript takes the HTML contents of an email and stores it in a string and again pastes the html content to webpage.html
. But, when I open webpage.html
, it displays all the HTML tags as a text rather than HTML view.
set mytext to string
tell application "Microsoft Outlook"
set the_messages to selection
repeat with this_message in the_messages
set mytext to content of this_message
end repeat
end tell
tell application "TextEdit"
activate
make new document
set text of document 1 to mytext as text
save document 1 in "/Users/mymac/Desktop/webpage.html"
end tell
The problem here is, it pastes the entire HTML as plain text to the webpage.html
. So the content now appears with all tags. How can I make the webpage appear with HTML formatting using Applescript.
EDIT:
I have uploaded the webpage.html file here
This is the view which is rendered in the reading pane of the outlook mail window after doing modifications.
set mytext to string
set hello to "hello this is testing"
set outputText to string
--get the content of a outlook message
tell application "Microsoft Outlook"
set the_messages to selection
repeat with this_message in the_messages
--set mytext to content of this_message
set mytext to source of this_message
end repeat
--adding some text to the content of the message
set mytext to mytext & hello
end tell
--pasting the content to a html file
tell application "TextEdit"
activate
make new document
set text of document 1 to mytext as text
--set source of document 1 to mytext as text
save document 1 in "/Users/mymac/Desktop/webpage.html"
end tell
--reading the contents from the html file
set theFile to "/Users/mymac/Desktop/webpage.html"
open for access theFile
set fileContents to (read theFile)
close access theFile
--pasting the modified contents to the outlook email
tell application "Microsoft Outlook"
set the_messages to selection
repeat with this_message in the_messages
set content of this_message to fileContents --modified email
--set fileContents to source of this_message(this does not modify the source of the message in view pane,Remains intact the original source)
end repeat
end tell
Question:
How to view the email as it is sent to the user, even after doing modifications?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
阅读webpage.html文件的源代码,而不是文件的内容。这解决了我的问题。
Read the source of webpage.html file rather than the content of the file. This solved my problem.