I am using Visual Studio 2010 with VSTO. Presently, I am working on modifying the contents of the body through a ribbon button, after the email has been typed.
I am aware the Word Editor is the default editor in Outook 2007. So how can I get the text of the body to perform search and replace operations when using word editor for the inspector window(compose mail window)?
I have a macro code in VBA, which works perfectly fine. I want to convert this code into C sharp which will work when the ribbon button is clicked in compose mail window.
Sub ASAtoHyperlinkCompose()
Dim uiInspector As Outlook.Inspector
Dim uiObject As Object
Dim uiItem As Outlook.MailItem
Dim uiDoc As Word.Document
Set uiInspector = Application.ActiveInspector
Set uiObject = uiInspector.CurrentItem
If uiObject.MessageClass = "IPM.Note" And _
uiInspector.IsWordMail = True Then
Set uiItem = uiInspector.CurrentItem
Set uiDoc = uiInspector.WordEditor
With uiDoc.Range.Find
.Text = "ASA^$^$^#^#^#^#^#"
While .Execute
.Parent.Hyperlinks.Add .Parent, _
"http://stack.com=" & .Parent.Text & "outlook2007"
.Parent.Collapse wdCollapseEnd
Wend
End With
End If
End Sub
I’m not familiar with Outlook’s automation and toolkit. This is more or less the same code converted to C#. If nothing else it is a start. There is no C# equivalent With statement FYI.