Get content type of email, Outlook 2011

I have a lovely script which is working great at the moment with AppleScript and Outlook.

tell application "Microsoft Outlook"
	set selected_folder_name to name of selected folder
	set selected_mail to messages of mail folder selected_folder_name
	-- this line replaces a tonne of other text, it's for simplisticty only
	set msg to item 1 of selected_mail as text
	set msgContent to content of msg as text
	if msgContent contains "</html>" then
		tell application "Finder"
			set msgContentSnipped to text 1 thru ((offset of "/body" in msgContent) - 2) of msgContent
		end tell
		set pPosixPath to (the POSIX path of prePos) as text
		set msgContentFinal to msgContentSnipped & "<B>Trust No One: They are all watching you!</B></BODY></HTML>"
		set content of msg to msgContentFinal
	end if
end tell

I’ve stuck most of it here as I believe in giving back to the community :slight_smile:


I know that Outlook 2011 supports content type of text also

I haven’t found a way to detect the content type of an email. I suppose if the email content DOESN’T content then you know it’s text? I’d rather do something a little less, well, fudgey

Hi Woggledog,

In Outlook, message has a property called “has html” that return boolean value to Indicates whether a message has html text. Remember to have latest updates applied. First version of Outlook (when was released) have a bug about this but all latest version since version pack 1, works good.
In addition you can get with other properties:

content (text): The HTML content of a message.
plain text content (text) : The content of a message as plain text.

Stefano - Ame