0

我试图在 Outlook 约会正文中显示 HTML 内容,但无法(我尝试了正文和 FTFbody 选项)。任何人请帮助我。下面是我的代码。

private void button1_Click(object sender, RibbonControlEventArgs e)
{
    Outlook.Application application = Globals.ThisAddIn.Application;
    Outlook.Inspector inspector = application.ActiveInspector();
    Outlook.AppointmentItem AppointmentItem = inspector.CurrentItem as Outlook.AppointmentItem;

    if (AppointmentItem != null)
    {
        if (AppointmentItem.EntryID == null)
        {
            string messageBody = string.Empty;
            string defaultMessageBody = "Click <a href='https://www.google.com/' > here </a>";
            AppointmentItem.Subject = "This text was added by using code";
            AppointmentItem.Recipients.Add("testuser1@gmail.com");
            AppointmentItem.Location = "INDIA";
            //AppointmentItem.RTFBody = System.Text.Encoding.Default.GetBytes(defaultMessageBody);
            AppointmentItem.Body = defaultMessageBody;
            AppointmentItem.Save();
        }
    }
}

[默认 OutLook 预约正文消息]

4

2 回答 2

1

首先,您不应该在服务(例如 ASP.Net)下使用 Outlook(或任何其他 Office 应用程序)。

其次,Outlook 2016 及更高版本在约会中支持 HTML,但尚未通过 Outlook 对象模型公开该支持。您可以尝试使用 设置PR_HTML属性(DASL 名称http://schemas.microsoft.com/mapi/proptag/0x10130102AppointmentItem.PropertyAccessor.SetProperty,但在您完全取消引用并重新打开该项目之前,Outlook 不会看到您的更改。

于 2019-11-29T03:14:44.750 回答
0

我们需要将 HTML 内容转换为字节数组,然后将其显示在 HTML 正文中,然后我们才能获得完整的 html 正文。直到除非进行字节转换,否则我们无法获取约会插件中的 html 内容。如果它解决了您的问题,请投票。谢谢 :)

于 2020-01-30T06:54:44.107 回答