Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在Outlook加载项中的Outlook.AppointmentItem正文中显示HTML内容_C#_Asp.net_Outlook Addin - Fatal编程技术网

C# 如何在Outlook加载项中的Outlook.AppointmentItem正文中显示HTML内容

C# 如何在Outlook加载项中的Outlook.AppointmentItem正文中显示HTML内容,c#,asp.net,outlook-addin,C#,Asp.net,Outlook Addin,我试图在Outlook约会正文中显示HTML内容,但无法同时显示正文和FTFbody选项。任何人都可以帮助我。下面是我的代码 private void button1_Click(object sender, RibbonControlEventArgs e) { Outlook.Application application = Globals.ThisAddIn.Application; Outlook.Inspector inspector = application.Ac

我试图在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();
        }
    }
}

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


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

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