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_messa开发者_StackOverflowge
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?
Read the source of webpage.html file rather than the content of the file. This solved my problem.
精彩评论