1

This is what I have so far:

RichTextBox rtb = new RichTextBox();
rtb.Rtf = System.Text.Encoding.UTF8.GetString(item.RTFBody);
rtb.Select(rtb.TextLength, 0);
rtb.SelectedRtf = @"{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard {\par} {\field{\*\fldinst HYPERLINK ""http://www.google.com/""}{\fldrslt Click Here}}";

item.RTFBody = System.Text.Encoding.UTF8.GetBytes(rtb.Text);

The code runs fine, and adds the "Click Heere" text, but there is no link attached to the text. I think I'm close, but I don't know much about RTF formatting. Any help would be greatly appreciated!

Lin Meyer
  • 712
  • 5
  • 19

2 Answers2

1

Take a look at the What is the RTF syntax for a hyperlink? thread which describes exactly the same question:

RTF field syntax is covered in the specification, and using the HYPERLINK instruction will give you a link. This question shows a usage of the HYPERLINK instruction.

Also I'd suggest saving the Outlook item and re-open the inspector window anew. Hope it will help.

Community
  • 1
  • 1
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
1

You are reading back rtb.Text (plain text), not Rtf:

item.RTFBody = System.Text.Encoding.UTF8.GetBytes(rtb.Rtf);
Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • Thank you! You were right, using rtb.Rtf solved that problem. Do you know if there is a way to use non http/s protocols in RTF hyperlinks? The code now works fine for http://google.com, but I need it to open a link like this: h323://12345678. When using that, it is not clickable. Any ideas? Thanks again! – Lin Meyer Apr 02 '15 at 14:01
  • I actually just posted another question asking if it is possible, maybe someone knows of a workaround. If only Appointments had an HTMLBody - this would be much easier. Again, thanks for your time and help! – Lin Meyer Apr 02 '15 at 15:14