| Code level: intermediate Code area: Outlook Expert Techniques Printer Friendly Version | ||
| Title: Format selected text in HTML message | ||
| Description: These two macros demonstrate how to change the formatting of a message being composed in HTML format using the built-in Outlook editor, not WordMail. | ||
| Date: 12-Sep-2006 07:27 | ||
| Code level: intermediate | ||
| Code area: Outlook Expert Techniques | ||
| Posted by: Sue Mosher | ||
| Body: |
||
| All 10comments |
| Page [ 1 ] | ||
|
|
mark petryk
29-May-2008 08:03
I am formatting an appointment as HTML and applying it to a new appointment with redemption and .htmlBody followed by .display. The appointment display properly formatted, but when I 'save' the item manually (or through vbScript) it appears to be stripped of all html formatting. I can before saving scrape the body and paste it in to a new appointment and the formatting is preserved. So, I'm not sure why it's being lost when using straight vbScript. |
|
|
|
Sue Mosher
29-May-2008 08:29
Mark, only messages and posts support HTML item bodies, not appointments. If you look at the object browser, you'll see that there is no HTMLBody property. Appointment bodies are RTF, not HTML. The documentation on Redemption's SafeInspector object should give you what you need to handle it. |
|
|
|
mark petryk
29-May-2008 16:16
Thank you! I did notice that the object browser did not show an HtmlBody, but I thought that was just an anomoly. Funny the code through redemption doesn't crash. I'll review the SafeInspector documentation. |
|
|
|
Doug
13-Jun-2008 10:59
If you can't reference the Microsoft HTML Object Library (I can't because of corporate policy), I was able to get the following code to work without it. Sub Blue_Code_Highlight() Dim msg As Outlook.MailItem Dim insp As Outlook.Inspector Set insp = Application.ActiveInspector If insp.CurrentItem.Class = olMail Then Set msg = insp.CurrentItem If insp.EditorType = olEditorHTML Then Set hed = msg.GetInspector.HTMLEditor Set rng = hed.Selection.createRange rng.pasteHTML "<font style='color: blue; font-family:Times New Roman; font-size: 10pt;'>" & rng.Text & "</font><br/>" End If End If Set insp = Nothing Set rng = Nothing Set hed = Nothing Set msg = Nothing End Sub |
|
|
|
aribault
30-Mar-2009 09:41
Hi, Excuse me but I cannot update the property HTMLEditor (the createRange does nothing !). In the Microsoft documentation, it is written that this property is read only. Could you help me ? Thanks |
|
|
|
Sue Mosher
30-Mar-2009 15:39
aribault, HTMLEditor is an object property, which is almost always read-only. It is the properties and methods of the object that are used to do any updating. Also note that this approach does not work if Word is the email editor. |
|
|
|
shikha
23-Jul-2009 07:15
Hi Sue, I have created functions for sending emails etc throught Interop. Only problem Im facing is that its giving com exception, sometimes when outlook on server is closed, sometimes otherwise. Is ther any way to solve that |
|
|
|
Sue Mosher
23-Jul-2009 07:29
shikha, I don't see how that issue is related to the current code sample. I suggest you start a new discussion thread in the Outlook and .NET forum at http://www.outlookcode.com/messages.aspx?forumid=5 and show the code you're using to instantiate your Outlook.Application object. Outlook version is almost always relevant, too. |
|
|
|
San
19-May-2010 03:56
But how to get the HTML content from a word document to use in an outlook message? |
|
|
|
Sue Mosher
19-May-2010 06:16
San, if you want to send a message using the content of a Word document, use the technique demonstrated at http://www.outlookcode.com/codedetail.aspx?id=1333 |
|
| Page [ 1 ] | ||
| Post your comment name email |
