我正在尝试为 Outlook 创建一个新的日历事件。它创建成功,但是当来自另一个国家(另一个区域时间)的某个人打开它时,日期和时间不正确。
这是代码
Dim calendarEventText As StringBuilder = New StringBuilder
calendarEventText.AppendLine("BEGIN:VCALENDAR")
calendarEventText.AppendLine("PRODID:-//Company Name")
calendarEventText.AppendLine("VERSION:2.0")
calendarEventText.AppendLine("METHOD:REQUEST")
calendarEventText.AppendLine("BEGIN:VEVENT")
calendarEventText.AppendLine(String.Format("DTSTART:{0:yyyyMMddTHHmmssZ}", Convert.ToDateTime(changeStartDate.ToString)))
' I'm using the UTC time
calendarEventText.AppendLine(String.Format("DTSTAMP:{0:yyyyMMddTHHmmssZ}", DateTime.UtcNow))
calendarEventText.AppendLine(String.Format("DTEND:{0:yyyyMMddTHHmmssZ}", Convert.ToDateTime(changeEndDate.ToString)))
calendarEventText.AppendLine(String.Format("LOCATION:{0}", location.ToString))
calendarEventText.AppendLine(String.Format("UID:{0}", Guid.NewGuid()))
calendarEventText.AppendLine(String.Format("DESCRIPTION:{0}", _mail.Body))
calendarEventText.AppendLine(String.Format("X-ALT-DESC;FMTTYPE=text/html:{0}", _mail.Body))
calendarEventText.AppendLine(String.Format("SUMMARY:{0}", _mail.Subject))
calendarEventText.AppendLine(String.Format("ORGANIZER:MAILTO:{0}", _mail.From.Address))
If _mail.To.Count > 0 Then
calendarEventText.AppendLine(String.Format("ATTENDEE;CN=\{0}\;RSVP=TRUE:mailto:{1}", _mail.To(0).DisplayName, _mail.To(0).Address))
Else
calendarEventText.AppendLine(String.Format("ATTENDEE;CN=\{0}\;RSVP=TRUE:mailto:{1}", "", ""))
End If
calendarEventText.AppendLine("BEGIN:VALARM")
calendarEventText.AppendLine("TRIGGER:-PT15M")
calendarEventText.AppendLine("ACTION:DISPLAY")
calendarEventText.AppendLine("DESCRIPTION:Reminder")
calendarEventText.AppendLine("END:VALARM")
calendarEventText.AppendLine("END:VEVENT")
calendarEventText.AppendLine("END:VCALENDAR")
Dim ct As System.Net.Mime.ContentType = New System.Net.Mime.ContentType("text/calendar")
ct.Parameters.Add("method", "REQUEST")
Dim avCal As AlternateView = AlternateView.CreateAlternateViewFromString(calendarEventText.ToString(), ct)
如何添加时区支持?
环境:
- .NET 2.0
谢谢你的帮助。