我无法通过C#在Outlook约会中插入超级链接

时间:2018-07-30 13:24:49

标签: c# outlook outlook-addin rtf

我正在使用Visual Studio 2010和Outlook2013。我试图在约会正文/ rtfbody中发送超链接,但我得到了单独的文本和URL。在这里,我分享了我的代码和输出。

Microsoft.Office.Interop.Outlook.Application outlookApp = new Microsoft.Office.Interop.Outlook.Application(); // creates new outlook app
Microsoft.Office.Interop.Outlook.AppointmentItem oAppointment = (Microsoft.Office.Interop.Outlook.AppointmentItem)outlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);

oAppointment.Subject = "Enquiry Changes made to " + "Anbuchelvan" + "'s enquiry"; // set the subject
RichTextBox rtb = new RichTextBox();

rtb.Rtf = System.Text.Encoding.UTF8.GetString(oAppointment.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}}";

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

// oAppointment.Body =  // set the body
oAppointment.Location = "Nicks Desk!"; // set the location
oAppointment.Start    = Convert.ToDateTime(DateTime.Now); // Set the start date 
oAppointment.End      = Convert.ToDateTime(DateTime.Now); // End date 
oAppointment.ReminderSet = true; // Set the reminder
oAppointment.ReminderMinutesBeforeStart = 15; // reminder time
oAppointment.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh; // appointment importance
oAppointment.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olBusy;
oAppointment.Recipients.ResolveAll();
oAppointment.Display(true);
oAppointment.Save();

我的输出是:

  

Click Here <http://www.google.com/>

image

1 个答案:

答案 0 :(得分:0)

我们在使用HTML的这种实现方面取得了巨大的成功。

<a href='http://www.google.com'>Click Here</a>
相关问题