简体   繁体   中英

Saving An Outlook Item from asp.net web application

I have a requirement of allowing the users to save an event from an application as outlook calendar item. The code that I am using is allowing to Open the item as Outlook item. Next the user can Save&Close. On using the save prompt the item is saved as first .ics file on the system and then it needs to be reopened in outlook to save it in outlook calendar but we want direct save in outllok without being saved on the system. Please suggest. The code used is:

// Define the event.
            sbICSFile.AppendLine("BEGIN:VEVENT");

            //sbICSFile.Append("DTSTART;TZID=" + "US/Eastern" + ":");
            sbICSFile.Append(StartYear);
            sbICSFile.Append(
               FormatDateTimeValue(StartMonth));
            sbICSFile.Append(
               FormatDateTimeValue(StartDay) + "T");
            sbICSFile.AppendLine("000000");

            //sbICSFile.Append("DTEND;TZID=" + "US/Eastern" + ":");
            sbICSFile.Append(EndYear);
            sbICSFile.Append(
              FormatDateTimeValue(EndMonth));
            sbICSFile.Append(
              FormatDateTimeValue(EndDay) + "T");
            sbICSFile.AppendLine("000000");

            sbICSFile.AppendLine("SUMMARY:" + Subject);
            sbICSFile.AppendLine("DESCRIPTION:" + EventDetails);
            sbICSFile.AppendLine("UID:1");
            sbICSFile.AppendLine("SEQUENCE:0");

            sbICSFile.Append("DTSTAMP:" + dtNow.Year.ToString());
            sbICSFile.Append(FormatDateTimeValue(dtNow.Month));
            sbICSFile.Append(FormatDateTimeValue(dtNow.Day) + "T");
            sbICSFile.Append(FormatDateTimeValue(dtNow.Hour));
            sbICSFile.AppendLine(FormatDateTimeValue(dtNow.Minute) + "00");

            sbICSFile.AppendLine("END:VEVENT");
            sbICSFile.AppendLine("END:VCALENDAR");

            Response.Clear();
            Response.ClearHeaders();
            Response.Charset = "";
            Response.ContentType = "text/calendar";
            Response.AddHeader("content-disposition",
                "attachment; filename=" + Subject + "CalendarEvent.ics");
            Response.Write(sbICSFile);
            Response.End();

通过在邮件附件中附加.ICS文件将邮件发送给与会者。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM