如何设置邀请的格式,使其在 Outlook 和 IBM Notes 中运行良好



我们的 C# 应用程序使用 System.Net.Mail.SmtpClient 发送电子邮件邀请。我们曾经用HTML格式化它们,在Microsoft Outlook中看起来很合适。现在,他们也必须在IBM Notes中工作。

然而,Notes似乎拒绝任何在邀请中设置任何样式的尝试。它从 HTML 中提取文本部分,并将它们作为无格式文本放入其描述字段中。

我们的实现使用带有ALT-REP引用和两个替代视图的text/calendar

ContentType contentType = new ContentType("text/html; charset=UTF-8");
AlternateView alternateView = AlternateView.CreateAlternateViewFromString(descriptionContent, contentType);
message.AlternateViews.Add(alternateView);
contentType = new ContentType("text/calendar; method=REQUEST; charset=UTF-8");
contentType.Parameters.Add("Content-Class", "urn:content-classes:calendarmessage");
alternateView = AlternateView.CreateAlternateViewFromString(invitationContent, contentType);
message.AlternateViews.Add(alternateView);

其中descriptionContent是 HTML 格式的内容。

invitationContent

StringBuilder builder = new StringBuilder();
builder.Append("BEGIN:VCALENDARrn");
builder.Append("PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//ENrn");
builder.Append("VERSION:2.0rn");
builder.Append("METHOD:REQUESTrn");
builder.Append("BEGIN:VEVENTrn");
builder.Append("ORGANIZER;CN="The Full Name":MAILTO:the-to-address@example.orgrn");
builder.Append("SUMMARY;CHARSET=iso-8859-1;LANGUAGE=de-ch:Some Titlern");
builder.Append("DTSTART:" + String.Format("{0:yyyyMMdd'T'HHmm'00'}", invitationStart) + "rn");
builder.Append("DTEND:" + String.Format("{0:yyyyMMdd'T'HHmm'00'}", invitationEnd) + "rn");
builder.Append("LOCATION;CHARSET=iso-8859-1:Some addressrn");
builder.Append("UID:" + Guid.NewGuid().ToString().ToUpper() + "rn");
builder.Append("DTSTAMP:" + String.Format("{0:yyyyMMdd'T'HHmm'00'}", DateUtil.GetToday()) + "rn");
builder.Append("DESCRIPTION;ALTREP="CID:<eventDescriptionHTML>"rn");
builder.Append("BEGIN:VALARMrn");
builder.Append("TRIGGER:-PT15Mrn");
builder.Append("ACTION:DISPLAYrn");
builder.Append("DESCRIPTION:Reminderrn");
builder.Append("END:VALARMrn");
builder.Append("END:VEVENTrn");
builder.Append("END:VCALENDAR");

例如,descriptionContent

...
<h1>A title</h1>
<h2>A subtitle</h2>
<p>A paragraph</p>
...

这将在MS Outlook中直接显示,但在Notes中,邀请说明包含纯"标题A副标题A段落"文本。

您可以从 Notes

客户机中的 Notes 日历中将 Notes 日历条目导出为 ICS 格式。

使用所需的描述创建邀请,将其导出并检查.ics以查看需要添加到代码中的内容

最新更新