2017-08-21 6 views
1

Je suis en train d'envoyer une demande de réunion par courriel à l'utilisateur dont j'ai besoin. Les heures de réunion sont de 8h30 à 9h00. Lorsque l'utilisateur reçoit l'e-mail et l'invitation, il est en heure UTC. Cela signifie que la réunion a lieu de 4h30 à 5h00. Ce n'est pas le cas et les problèmes de fuseau horaire Outlook comme le mien est défini sur EST. J'ai essayé de spécifier en utilisant DateTime et d'autres méthodes, mais aucun d'entre eux ne fonctionne. Pourquoi cela pourrait-il toujours être en UTC que je spécifie ou non?Outlook rencontre les horaires en UTC pas EST

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

       msg.From = new MailAddress("[email protected]", "[email protected]"); 
       msg.To.Add(new MailAddress("[email protected]", "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); 

Répondre

1

La question était cette ligne:

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

Retrait du 'z' à partir du moment spécifié, il arrête de liaison avec un fuseau horaire.