我需要从我拥有的 Web 应用程序发送 Outlook 日历约会。这一切都很好,除了我无法获得我想要的格式。似乎 Outlook 将 HTML 转换为 RTF,并且表格等内容无法正确呈现。这是我希望电子邮件看起来像的示例。
– Application Production Release Details:
RFC Ticket #: XXXXX Project / Release Name: XXXX
Release Date: 2/22/2012 Release Time: 10:00PM
CAB Approval Status: Approved
Contact Information:
Project / Team Lead: XXXXXXX On Call DSE: XXXXX
Phone: XXXXXXX Phone: XXXXXXX
Migration Instructions:
Step 1: Browse to RMT Home Page:
Step 2: Under PRODUCTION Servers Section, Select the below mentioned Deploy Dashboard
Step 3: Login using your Network Credentials
Step 4: Press the Migrate button adjacent to the Application listed below
Step 5: Enter RFC Number and Hit Migrate
Step 6: Wait for the e-Mail notification OR Use the Refresh Status button to check the Migration Status on the dashboard
Step 7: Logout
Load Balanced Environment: Repeat Steps for PROD-2 Server (Production Server are load balanced if below entry says PROD-1 / PROD-2)
Deploy Dashboard(s) Application
High Availability PROD-1 / PROD-2 ClaimsSupport
High Availability PROD-1 / PROD-2 PolicySupport
Connections WesternStateQQ
AgentSite PROD-1 / PROD-2 EBQ.BA
请注意这是多么漂亮和整洁?我可以简单地用 HTML 表来做这件事,但是每次渲染都会变得很不稳定(最明显的是在底部显示服务器和应用程序,因为字段是可变长度的,除了最后的空格之外没有其他办法)。有解决这个问题的方法吗?我已经将 AlternateView 添加到 html 的 MailMessage 中,并将 IsBodyHTML 设置为 true。这是我的消息代码
SmtpClient sc = new SmtpClient("server");
MailMessage msg = new MailMessage();
msg.From = new MailAddress("email@t.com", "email@t.com");
msg.To.Add(new MailAddress("email@t.com", "email@t.com"));
msg.Subject = release.RFCTicket + " Instructions";
msg.Body = "Here are the migration instructions";
StringBuilder str = new StringBuilder();
str.AppendLine("BEGIN:VCALENDAR");
str.AppendLine("PRODID:-//");
str.AppendLine("VERSION:2.0");
str.AppendLine("METHOD:REQUEST");
str.AppendLine("BEGIN:VEVENT");
str.AppendLine("DTSTART:" + Convert.ToDateTime(release.ReleaseDateString + " " + release.ReleaseTimeString).ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"));
str.AppendLine("DTSTAMP:" + DateTime.Now.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"));
str.AppendLine("DTEND:" + Convert.ToDateTime(release.ReleaseDateString + " " + release.ReleaseTimeString).ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"));
str.AppendLine("LOCATION: Call");
str.AppendLine(string.Format("UID:{0}", Guid.NewGuid()));
str.AppendLine(string.Format("DESCRIPTION:{0}", msg.Body));
str.AppendLine(string.Format("X-ALT-DESC;FMTTYPE=text/html:{0}", msg.Body));
str.AppendLine(string.Format("SUMMARY:{0}", msg.Subject));
str.AppendLine(string.Format("ORGANIZER:MAILTO:{0}", msg.From.Address));
str.AppendLine(string.Format("ATTENDEE;CN=\"{0}\";RSVP=TRUE:mailto:{1}", msg.To[0].DisplayName, msg.To[0].Address));
str.AppendLine("BEGIN:VALARM");
str.AppendLine("TRIGGER:-PT15M");
str.AppendLine("ACTION:DISPLAY");
str.AppendLine("DESCRIPTION:Reminder");
str.AppendLine("END:VALARM");
str.AppendLine("END:VEVENT");
str.AppendLine("END:VCALENDAR");
System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType("text/calendar");
ct.Parameters.Add("method", "REQUEST");
AlternateView avCal = AlternateView.CreateAlternateViewFromString(str.ToString(), ct);
msg.AlternateViews.Add(avCal);
AlternateView body1 = AlternateView.CreateAlternateViewFromString(body, new System.Net.Mime.ContentType("text/html"));
msg.AlternateViews.Add(body1);
msg.IsBodyHtml = true;
sc.Send(msg);
任何帮助,将不胜感激。谢谢