Alternatives for replacing text selection under Outlook with custom HTML code
I need to replace an user selection while editing an Outlook e-mail with my custom HTML code.

I tried two approaches:

###Using the Clipboard###

 1. In HTML mode.
 1. Getting the Word.Range from the Word.Selection.
 1. Doing a range.Copy() to put it in the clipboard
 1. Convert inputString to outputString
 1. Replacing the selection with outputString with range.PasteSpecial(...)

###Using the Open XML Format###

 1. In HTML mode.
 1. Getting the Word.Range from the Word.Selection.
 1. Doing a range.Copy() to put it in the clipboard
 1. Convert inputString to outputString (in Office Open XML format, knowing how to craft it to produce a specific HTML).
 1. Replacing the selection with outputString with range.InsertXML(...)

The issues are:

 1. When using the clipboard it crashes sometimes. There are references about checking the clipboard state but I think I've tried the known alternatives.
 1. To use the insertXML you need to have Microsoft Word installed. You can't do an insertXML with Outlook installed alone. Look at: [Impact of deploying Outlook 2007 without Word 2007][1] for further information.

Do you know more alternatives? I can think of adding the elements myself like using InsertParagraph, but I am not sure if I can add hyperlinks or will experience similar issues.






  [1]: http://technet.microsoft.com/en-us/library/cc179031%28v=office.12%29.aspx
Alternatives for replacing text selection under Outlook with custom HTML code
===

I need to replace an user selection while editing an Outlook e-mail with my custom HTML code.

I tried two approaches:

###Using the Clipboard###

 1. In HTML mode.
 1. Getting the Word.Range from the Word.Selection.
 1. Doing a range.Copy() to put it in the clipboard
 1. Convert inputString to outputString
 1. Replacing the selection with outputString with range.PasteSpecial(...)

###Using the Open XML Format###

 1. In HTML mode.
 1. Getting the Word.Range from the Word.Selection.
 1. Doing a range.Copy() to put it in the clipboard
 1. Convert inputString to outputString (in Office Open XML format, knowing how to craft it to produce a specific HTML).
 1. Replacing the selection with outputString with range.InsertXML(...)

The issues are:

 1. When using the clipboard it crashes sometimes. There are references about checking the clipboard state but I think I've tried the known alternatives.
 1. To use the insertXML you need to have Microsoft Word installed. You can't do an insertXML with Outlook installed alone. Look at: [Impact of deploying Outlook 2007 without Word 2007][1] for further information.

Do you know more alternatives? I can think of adding the elements myself like using InsertParagraph, but I am not sure if I can add hyperlinks or will experience similar issues.






  [1]: http://technet.microsoft.com/en-us/library/cc179031%28v=office.12%29.aspx