我正在尝试创建一个 vCalendar 约会以发送给我们的客户。日期和时间是诊所预约的。生成 vCal 的服务器在东部时间,但我们的客户端遍布全国。时间和日期与时区无关,因为它是由他们所见的诊所设置的。我需要使用特定的日期和时间发送 vCal,而不是根据时区调整的日期和时间。这是我现在使用的代码,但无论我做什么,它都会根据客户端的时区进行调整,这会导致他们的约会时间不正确。
Private Function CreateCalendarItem(ByVal Mail As System.Net.Mail.MailMessage, ByVal PlainText As String, ByVal ApptDateTime As String) As System.Net.Mail.AlternateView
Dim ApptDate As DateTime = CDate(ApptDateTime)
Dim calendarEventText As StringBuilder = New StringBuilder
calendarEventText.AppendLine("BEGIN:VCALENDAR")
calendarEventText.AppendLine("METHOD:REQUEST")
calendarEventText.AppendLine("PRODID:-//MyCompanyName")
calendarEventText.AppendLine("VERSION:2.0")
calendarEventText.AppendLine("BEGIN:VEVENT")
calendarEventText.AppendLine("DTSTART:" & ApptDate.ToUniversalTime.ToString("yyyyMMddTHHmmss"))
calendarEventText.AppendLine("DTSTAMP:" & ApptDate.ToUniversalTime.ToString("yyyyMMddTHHmmss"))
calendarEventText.AppendLine("DTEND:" & ApptDate.ToUniversalTime.ToString("yyyyMMddTHHmmss"))
calendarEventText.AppendLine("UID:" & Guid.NewGuid().ToString)
calendarEventText.AppendLine("DESCRIPTION:" & PlainText)
calendarEventText.AppendLine("X-ALT-DESC;FMTTYPE=text/html:" & PlainText)
calendarEventText.AppendLine("SUMMARY:" & Mail.Subject)
calendarEventText.AppendLine("ORGANIZER:MAILTO:" & Mail.From.Address)
If Mail.To.Count > 0 Then
calendarEventText.AppendLine("ATTENDEE;CN=\" & Mail.To(0).DisplayName & "\;RSVP=FALSE:mailto:" & Mail.To(0).Address)
Else
calendarEventText.AppendLine("ATTENDEE;CN=\\;RSVP=FALSE:mailto" & "")
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 System.Net.Mail.AlternateView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(calendarEventText.ToString(), ct)
Return avCal
End Function
任何帮助将不胜感激。谢谢您的意见。