【问题标题】:Outlook meeting schedules in UTC not ESTUTC 而非 EST 的 Outlook 会议时间表
【发布时间】:2017-08-22 00:55:18
【问题描述】:

我已成功向我需要的用户发送电子邮件会议请求。会议时间为上午 8:30 至上午 9:00。当用户收到电子邮件和邀请时,它是 UTC 时间。这意味着会议是从凌晨 4:30 到凌晨 5:00。这不是 Outlook 时区问题,因为我的设置为 EST。我试图指定使用DateTime 和其他方法,但它们都不起作用。无论我是否指定,为什么这总是在UTC?

                SmtpClient MyMail = new SmtpClient("000.000.000.00");
                MyMail.DeliveryMethod = SmtpDeliveryMethod.Network;
                MailMessage msg = new MailMessage();

                msg.From = new MailAddress("noreply@xxxx.org", "noreply@xxxx.org");
                msg.To.Add(new MailAddress("xxxx@xxxx.org", "Your Name"));
                msg.Subject = "Send Calendar Appointment Email";
                msg.Body = "Here is the Body Content";

                StringBuilder str = new StringBuilder();
                str.AppendLine("BEGIN:VCALENDAR");
                str.AppendLine("PRODID:-//A");
                str.AppendLine("VERSION:2.0");
                str.AppendLine("METHOD:REQUEST");
                str.AppendLine("BEGIN:VEVENT");

                str.AppendLine(string.Format("DTSTART:{0:yyyyMMddTHHmmssZ}", "20170822T083000Z"));
                //specifying what time zone
                var timeUtc = DateTime.UtcNow;
                TimeZoneInfo easternZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
                DateTime easternTime = TimeZoneInfo.ConvertTimeFromUtc(timeUtc, easternZone);

                str.AppendLine(string.Format("DTSTAMP:{0:yyyyMMddTHHmmssZ}", easternTime));

                str.AppendLine(string.Format("DTEND:{0:yyyyMMddTHHmmssZ}", "20170822T090000Z"));
                str.AppendLine("LOCATION: Here");
                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);

                MyMail.Send(msg);

【问题讨论】:

    标签: c# email datetime outlook timezone


    【解决方案1】:

    问题是这一行:

    str.AppendLine(string.Format("DTEND:{0:yyyyMMddTHHmmssZ}", "20170822T090000Z"));

    从指定时间删除“z”会阻止它与时区链接。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-05
      • 2021-10-27
      • 2021-11-15
      • 1970-01-01
      • 2021-09-28
      • 2018-09-07
      • 2018-05-11
      相关资源
      最近更新 更多