本文介绍了渲染HTML视图与HTML内容的字符串,并在网页上显示它/ Outlook作为HTML使用AppleScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这AppleScript的发生在一个字符串的邮件,并将其存储的HTML内容,并再次粘贴的HTML内容 webpage.html 。但是,当我打开 webpage.html ,它会显示所有的HTML标签为文本,而不是HTML视图。

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

这里的问题是,它粘贴完整的HTML作为纯文本到 webpage.html 。所以内容现在看来所有的标签。我怎样才能让网页看起来与使用AppleScript HTML格式。

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.

编辑:

我已经上传的文件webpage.html

I have uploaded the webpage.html file here

这是这是在的阅读窗格呈现这样修改之后Outlook邮件窗口。

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

问:

如何查看电子邮件,因为它被发送给用户,即使在做修改后

How to view the email as it is sent to the user, even after doing modifications?

推荐答案

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

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

这篇关于渲染HTML视图与HTML内容的字符串,并在网页上显示它/ Outlook作为HTML使用AppleScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 20:28