VCalendar消息体格式

时间:2012-02-17 20:38:04

标签: c# outlook vcalendar

我需要从我拥有的网络应用程序发送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表格做这件事,但渲染每次都会变得很糟糕(最明显的是它显示服务器和应用程序的底部,因为字段是可变长度的,最后没有办法容易,但是空格)。有没有解决这个问题的工作?我已经在MailMessage中为html添加了AlternateView,并将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);

任何帮助将不胜感激。感谢

0 个答案:

没有答案