日历会议请求不附带跟踪菜单

时间:2014-02-28 09:57:43

标签: c# asp.net calendar outlook

我们有会议室预订系统,可以生成MS Outlook日历会议。

此会议将保存在MS Outlook日历中。

但是当他/她从日历打开日历邀请时,管理员无法查看跟踪菜单如何通过asp.net C#启用跟踪菜单/选项? 示例代码如下所示。

    SmtpClient sc = new SmtpClient(ConfigurationSettings.AppSettings["MailHost"].ToString());
    ClientTimeZone objClientTime = new ClientTimeZone();


        MailMessage msg = new MailMessage();


        DateTime startDuration = new DateTime();
        DateTime endDuration = new DateTime();
        StringBuilder str = new StringBuilder();
        StringBuilder sbBody = new System.Text.StringBuilder();
        StringBuilder sbSubject = new System.Text.StringBuilder();
        DataRow drMeetingDetails=null;
        CommonUtility objCommonUtility;
        Stream contentStream;
        LinkedResource resc = null;
        int seq_no = 0;
        bool Recurrence = false;
        bool attachment = false;
        int Recurrence_Group_ID = 0;
        string freq = "";
        string reqID = "";
        string count = "";
        string byday = "";
        string location = "";
        //Create the Body in HTML format
string strBodyHTML = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">";
        strBodyHTML += "<HTML><HEAD><META http-equiv=Content-Type content=\"text/html; charset=iso-8859-1\">";
        strBodyHTML += "</HEAD><BODY><DIV><font face=verdana size=2>{0}";
        strBodyHTML += "</font></DIV></BODY></HTML>";

        str.AppendLine("BEGIN:VCALENDAR");
        str.AppendLine("PRODID:-//Niti Jotani");
        str.AppendLine("VERSION:2.0");


        str.AppendLine("BEGIN:VEVENT");



                    //strBodyHTML = string.Format(strBodyHTML, "", msg.From.DisplayName, startDuration.ToLongDateString() + " " + startDuration.ToLongTimeString(), endDuration.ToLongDateString() + " " + endDuration.ToLongTimeString(), System.TimeZone.CurrentTimeZone.StandardName, location, sbBody.ToString());
                    strBodyHTML = string.Format(strBodyHTML, sbBody.ToString());

                    msg.Subject = sbSubject.ToString();
                    //msg.Body = sbBody.ToString();
                    msg.IsBodyHtml = true;
                    msg.Body = strBodyHTML;
                    msg.BodyEncoding = System.Text.Encoding.ASCII;

                    seq_no = Convert.ToInt32(drMeetingDetails["Update_Iterations"].ToString());
                    seq_no = seq_no + 1;
                    Boolean IsPrivate = Convert.ToBoolean(drMeetingDetails["IS_Private"].ToString());
                    if (IsPrivate)
                    {
                        str.AppendLine("CLASS:PRIVATE");
                    }
                    else
                    {
                        str.AppendLine("CLASS:PUBLIC");
                    }
                    //str.AppendLine(string.Format("DTSTART:{0:yyyyMMddTHHmmssZ}", startDuration));
                    //str.AppendLine(string.Format("DTEND:{0:yyyyMMddTHHmmssZ}", endDuration));
                    str.AppendLine(string.Format("DTSTART:{0:yyyyMMddTHHmm00Z}", startDuration));
                    str.AppendLine(string.Format("DTEND:{0:yyyyMMddTHHmm00Z}", endDuration));
                    str.AppendLine("LOCATION:" + drMeetingDetails["Room_Name"].ToString() + "");
                    str.AppendLine("SEQUENCE:" + seq_no.ToString() + "");
                    str.AppendLine(string.Format("UID:{0}", drMeetingDetails["Request_id"].ToString()));
                    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;CN=\"{0}\":MAILTO:{1}", msg.From.DisplayName, msg.From.Address));

        foreach (MailAddress strInvite in msg.To)
        {
            str.AppendLine(string.Format("ATTENDEE;CN=\"{0}\";RSVP=TRUE:mailto:{1}", strInvite.DisplayName, strInvite.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");               

        /*HTML Body*/
        //System.Net.Mime.ContentType bodyHtml = new System.Net.Mime.ContentType("text/html");
        AlternateView viewHTML = AlternateView.CreateAlternateViewFromString(msg.Body, new ContentType(MediaTypeNames.Text.Html));
        msg.AlternateViews.Add(viewHTML);

        /*Calendar Body*/
        System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType("text/calendar");
        ct.Parameters.Add("method", "REQUEST");
        //if (attachment) viewHTML.LinkedResources.Add(resc);
        AlternateView avCal = AlternateView.CreateAlternateViewFromString(str.ToString(), ct);

        msg.AlternateViews.Add(avCal);                
        // If we are using the IIS SMTP Service, we can write the message directly to the //PickupDirectory and bypass the Network Layer
        sc.DeliveryMethod = SmtpDeliveryMethod.Network;
        sc.Send(msg);

1 个答案:

答案 0 :(得分:0)

我不熟悉SMTP API,但可能未将此vCal项目分配给适当的用户以为其分配会议组织者角色。我会使用Exchange Web服务来创建会议请求。