使用 Applescript 呈现包含 HTML 内容的字符串的 HTML 视图,并在网页/Outlook 中将其显示为 HTML

发布于 2024-11-19 16:29:24 字数 2324 浏览 0 评论 0原文

此 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 格式显示。

编辑:

我已在此处上传了webpage.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不寐倦长更 2024-11-26 16:29:25

阅读webpage.html文件的源代码,而不是文件的内容。这解决了我的问题。

Read the source of webpage.html file rather than the content of the file. This solved my problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文