locked
Generating Outlook Calendar with timezone difference RRS feed

  • Question

  • User69488508 posted

    Hi:

    I am able to generate a calendar successfully however, if someone from a different timezone accepts it does not adjust to their timezone.  Does anyone know how I can compensate for this in the following code?

    TrainingStart = Convert.ToDateTime(ReturnValue4);
    
                TrainingEnd = TrainingStart.AddMinutes(30);
    
                //Initialization
                MemoryStream mStream = new MemoryStream();
                StreamWriter sw = new StreamWriter(mStream);
                sw.AutoFlush = true;
    
                //Header
                sw.WriteLine("BEGIN:VCALENDAR");
                sw.WriteLine("VERSION:2.0");
                sw.WriteLine("PRODID:-//Flo Inc.//FloSoft//EN");
                sw.WriteLine("BEGIN:VEVENT");
    
                //Body
    
                sw.WriteLine("DTSTART:" + TrainingStart.ToString("s"));
                sw.WriteLine("DTEND:" + TrainingEnd.ToString("s"));
                sw.WriteLine("LOCATION:" + Location);
                sw.WriteLine("X-ALT-DESC;FMTTYPE=text/html:" + Description.Replace("\n", " "));
    
                sw.WriteLine("SUMMARY:" + Subject);
    
    
                //Footer
                sw.WriteLine("PRIORITY:" + Priority);
                sw.WriteLine("END:VEVENT");
                sw.WriteLine("END:VCALENDAR");
    
    
    
                //Make it Downloadable
                Response.Clear();
                Response.AppendHeader("Content-Disposition", "attachment; filename=Add2Calendar.ics");
                Response.AppendHeader("Content-Length", mStream.Length.ToString());
                Response.ContentType = "html/x-vCalendar";
                //Response.ContentType = "application/download";
                Response.BinaryWrite(mStream.ToArray());
                Response.End();
                sqlcon.Close();
    Monday, February 28, 2011 9:26 AM

All replies

  • User69488508 posted

    Unfortunately this issue is still unresolved.  This is the code i have now.  A clause for each Timezone however they are off by 1 hour.  Not sure what i am missing.

    if (trainingtimezone.Equals("(EST)"))
                {
       
                    //Initialization
                    MemoryStream mStream = new MemoryStream();
                    StreamWriter sw = new StreamWriter(mStream);
                    sw.AutoFlush = true;
    
                    //Header
                    sw.WriteLine("BEGIN:VCALENDAR");
                    sw.WriteLine("VERSION:2.0");
                    sw.WriteLine("PRODID:-//Flo Inc.//FloSoft//EN");
                    sw.WriteLine("BEGIN:VEVENT");
    
                    //Body
                 
                    sw.WriteLine("DTSTART;TZID=US/Eastern:" + TrainingStart.ToString("s"));
                    sw.WriteLine("UTC-OFFSET:-0500");
                    sw.WriteLine("DTEND;TZID=US/Eastern:" + TrainingEnd.ToString("s"));
                    sw.WriteLine("LOCATION:" + Location);
                    sw.WriteLine("X-ALT-DESC;FMTTYPE=text/html:" + Description.Replace("\n", " "));
    
                    sw.WriteLine("SUMMARY:" + Subject);
    
    
                    //Footer
                    sw.WriteLine("PRIORITY:" + Priority);
                    sw.WriteLine("END:VEVENT");
                    sw.WriteLine("END:VCALENDAR");
    
    
    
                    //Make it Downloadable
                    Response.Clear();
                    Response.AppendHeader("Content-Disposition", "attachment; filename=Add2Calendar.ics");
                    Response.AppendHeader("Content-Length", mStream.Length.ToString());
                    Response.ContentType = "html/x-vCalendar";
                 
                    Response.BinaryWrite(mStream.ToArray());
                    Response.End();
    
                }
    
    Thursday, March 17, 2011 2:14 PM