Il formato utilizzato da molti programmi per lo scambio di appuntamenti è noto come vCalendar e si basa su un semplice file di testo, formatto a dovere.
In questo esempio generiamo un appuntamento impostando in maniera manuale le informazioni:
<SCRIPT RUNAT="SERVER" LANGUAGE="C#"> // funzione per generare l'appuntamento void Appointment(DateTime startDate, DateTime endDate, string subject, string location, string description) { // le date devono essere GMT int GMT = 1; startDate = startDate.AddHours(-GMT); endDate = endDate.AddHours(-GMT); // generazione del content Type Response.ContentType = "text/x-vcalendar"; Response.AddHeader("content-disposition", "inline; filename=" + location + ".vcs;"); // corpo dell'appuntamento Response.Write("BEGIN:VCALENDAR\r\n"); Response.Write("VERSION:1.0\r\n"); Response.Write("BEGIN: VEVENT\r\n"); Response.Write("DTStart:" + startDate.ToString("yyyyMMddTHHmmssZ") + "\r\n"); Response.Write("DTEnd:" + endDate.ToString("yyyyMMddTHHmmssZ") + "\r\n"); Response.Write("LOCATION;ENCODING=QUOTED-PRINTABLE:" + location + "\r\n"); Response.Write("SUMMARY;ENCODING=QUOTED-PRINTABLE:" + description + "\r\n"); Response.Write("DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" + subject + "\r\n"); Response.Write("UID:" + startDate.ToString("yyyyMMddTHHmmssZ") + endDate.ToString("yyyyMMddTHHmmssZ") + "\r\n"); Response.Write("PRIORITY:3\r\n"); Response.Write("End:VEVENT\r\n"); Response.Write("End:VCALENDAR\r\n"); } void Page_Load() { // sostituire con dati prelevati da un database Appointment(DateTime.Now, DateTime.Now.AddMinutes(5), "Descrizione", "Location", "Corpo esteso dell'appuntamento"); } </SCRIPT>
Per estendere al meglio l'esempio è consigliabile creare un HttpHandler che provveda a prelevare direttamente i dati da un database.
Commenti
Per inserire un commento, devi avere un account.
Fai il login e torna a questa pagina, oppure registrati alla nostra community.
Approfondimenti
Nessuna risorsa collegata
I più letti di oggi
- Selettore CSS :has() e i suoi casi d'uso avanzati
- Microsoft Security Bulletin MS04-013
- Microsoft Security Bulletin MS05-002
- Accedere ai dati di routing da code-behind in ASP.NET 4.0
- Differenziare il markup di ASP.NET Core in base all'ambiente di esecuzione
- Blazor Conference 2020 Live - Online
- Speciale Silverlight 5: tutte le novità