0

クライアントに送信する 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

どんな助けでも大歓迎です。ご意見ありがとうございます。

4

1 に答える 1

0

以下を使用します。

calendarEventText.AppendLine("DTSTART:" & ApptDate.ToUniversalTime.ToString("yyyyMMddTHHmmssZ"))
calendarEventText.AppendLine("DTSTAMP:" & ApptDate.ToUniversalTime.ToString("yyyyMMddTHHmmssZ"))
calendarEventText.AppendLine("DTEND:"   & ApptDate.ToUniversalTime.ToString("yyyyMMddTHHmmssZ"))

DATE-TIME 文字列形式の末尾に「Z」を追加したことに注意してください。「Z」は、vCalendar ファイル パーサーが日時の値が UTC 時間であることを認識する方法です。

RFC 5545 Date-Time spec info を参照してください

于 2015-12-10T19:27:03.197 に答える