Select Text in body using Redemption

M

Michael Salz

I am trying to select text within the body of an e-mail, click a button on a
toolbar and have the selected text appear in a message box.

I have implemented the SafeInspector class of Redemption and have
implemented the following code within the "Click" event handler function of a
toolbar button. It works great when I actually open the e-mail and select
the text. However, if I do not open the e-mail, but highlight the text in
the preview pane the Message Box pops up with no text. Thanks in advance.

Dim objoutlook As Outlook.Application = _Module.HostApplication

Dim sel As Outlook.Selection = objoutlook.ActiveExplorer.Selection



If sel.Count > 0 Then

Dim selobject As Object = Nothing

selobject = sel.Item(1)

If TypeOf selobject Is Outlook.MailItem Then

Dim mailitem As Outlook.MailItem = TryCast(selobject, Outlook.MailItem)

Dim editor As Outlook.Inspector = mailitem.GetInspector

Dim sinspector As Redemption.SafeInspector = New Redemption.SafeInspector

sinspector.Item = mailitem.GetInspector

MsgBox(sinspector.SelText)

If TypeOf selobject Is Outlook.MailItem Then

Dim mailitem As Outlook.MailItem = TryCast(selobject, Outlook.MailItem)

Dim editor As Outlook.Inspector = mailitem.GetInspector

Dim sinspector As Redemption.SafeInspector = New Redemption.SafeInspector

sinspector.Item = mailitem.GetInspector

MsgBox("You have selected: " & sinspector.SelText)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top