2

我想知道是否可以创建一个文件。新会议的 Ics 已经预先填写了收件人的电子邮件地址?是否可以将这些电子邮件地址作为参数发送?或者,这根本不可能?

像这样 :

在此处输入图像描述

这是我以前运行良好的代码:

    public string subject = string.Empty;
    public string body = string.Empty;
    public string uid = string.Empty;
    public DateTime date ;
    public Random rand;

    protected void Page_Load(object sender, EventArgs e)
    {
        rand = new Random();

        subject = "meeting event";
        body = "invitation meeting test";
        date = new DateTime(2014,1,1);
        uid = "CHE-106.802.033";

        openEventCalendar();
    }

    public void openEventCalendar()
    {
        Response.ContentType = "text/v-calendar";
        Response.AddHeader(

        "content-disposition", "attachment; filename=" + subject + ".ics");
        Response.Write("BEGIN:VCALENDAR" + Environment.NewLine);
        Response.Write(

        "PRODID: -//Microsoft Corporation//Outlook 12.0 MIMEDIR//EN" + Environment.NewLine);
        Response.Write("VERSION:2.0" + Environment.NewLine);
        Response.Write(

        "METHOD:PUBLISH" + Environment.NewLine);
        Response.Write("X-MS-OLK-FORCEINSPECTOROPEN:TRUE" + Environment.NewLine);
        Response.Write(

        "BEGIN:VEVENT" + Environment.NewLine);
        Response.Write("CLASS:PUBLIC" + Environment.NewLine);
        Response.Write(

        "CREATED:" + date.ToString("s") + Environment.NewLine);
        Response.Write("DESCRIPTION:" + body + Environment.NewLine);
        Response.Write(

        "DTEND:" + date.AddMinutes(30).ToString("s") + Environment.NewLine);
        Response.Write("DTSTAMP:" + date.ToString("s") + Environment.NewLine);
        Response.Write(

        "DTSTART:" + date.ToString("s") + Environment.NewLine);
        Response.Write("LAST-MODIFIED:" + date.ToString("s") + Environment.NewLine);
        Response.Write(

        "LOCATION:LM Reminder" + Environment.NewLine);
        Response.Write("PRIORITY:5" + Environment.NewLine);
        Response.Write(

        "SEQUENCE:0" + Environment.NewLine);
        Response.Write("SUMMARY;LANGUAGE=en-us:" + subject + Environment.NewLine);
        Response.Write(

        "TRANSP:OPAQUE" + Environment.NewLine);
        Response.Write(string.Format("UID:{0}-{1}", uid, rand.Next(1000)) + Environment.NewLine);

        //Response.Write(@"X-ALT-DESC;FMTTYPE=text/html:<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 3.2//EN>\n<HTML>\n<HEAD>\n<META NAME='Generator' CONTENT='MS Exchange Server version 08.00.0681.000'>\n<TITLE></TITLE>\n</HEAD>\n<BODY>\n\n\n<P DIR=LTR><SPAN LANG='en-us'></SPAN><SPAN LANG='en-us'></SPAN><SPAN LANG='en-us'><FONT SIZE=2 FACE='Arial'>" + Body + "</FONT></SPAN><SPAN LANG='en-us'></SPAN><SPAN LANG='en-us'></SPAN><SPAN LANG='en-us'></SPAN></P>\n\n</BODY>\n</HTML>" + Environment.NewLine);
        Response.Write("SUMMARY:" + subject + Environment.NewLine);
        Response.Write(

        "X-MICROSOFT-CDO-BUSYSTATUS:BUSY" + Environment.NewLine);
        Response.Write("X-MICROSOFT-CDO-IMPORTANCE:1" + Environment.NewLine);
        Response.Write(

        "BEGIN:VALARM" + Environment.NewLine);
        Response.Write("TRIGGER:-PT15M" + Environment.NewLine);
        Response.Write(

        "ACTION:DISPLAY" + Environment.NewLine);
        Response.Write("DESCRIPTION:Reminder" + Environment.NewLine);
        Response.Write(

        "END:VALARM" + Environment.NewLine);
        Response.Write("END:VEVENT" + Environment.NewLine);
        Response.Write(

        "END:VCALENDAR" + Environment.NewLine);

    }
4

2 回答 2

1

您可以将以下与会者行添加到您的文件中:

Response.Write("ATTENDEE;CN=\"Toto Tutu\";RSVP=TRUE:mailto:toto.tutu@test.com");
于 2013-06-05T13:47:18.237 回答
0

试试这种格式,在发送 ICS 文件之前填写这些字段,

        string ddstart = scheduledDate;
        string ddend = string.Empty;
        string duration = string.Empty;
        ddend = scheduledDate;

        string method = "REQUEST";
        string status = "CONFIRMED";
        string UID = Guid.NewGuid().ToString();
        string lastmodified = scheduledDate;
        string created = scheduledDate;
        string dtstamp = scheduledDate;
        string sequence ="0";
        Dictionary<string, string> keycollection = new Dictionary<string, string>{
                        {"[YYYYMMDD]", ddstart},
                        {"[SCHEDULERNAME]", scheduler},
                        {"[SCHEDULEREMAIL]", scheduleremail},   
                        {"[CANDIDATENAME]", applicant},
                        {"[CANDIDATEEMAIL]", applicantemail},
                        {"[INTERVIEWERNAME]", interviewer},
                        {"[INTERVIEWEREMAIL]", intervieweremail},
                        {"[YYYYMMDDTHHmmssZ]",lastmodified},
                        {"[VENUE]", venue},
                        {"[NOTES]",notes},
                        {"[GUID]",UID},
                        {"[subject]","Interview scheduled"},
                        {"[method]",method},
                        {"[status]",status},{"[sequence]",sequence}};

 attachment = StringHelpers.ReplaceStringValue(attachment, keycollection);
        byte[] byteArray = Encoding.UTF8.GetBytes(attachment);          
        MemoryStream MemoryStreamData= new MemoryStream(byteArray);

之后将此 ics 文件流添加到附件中。

            From = From,
            FromDisplayName = FromDisplayName,
            To = To,
            Cc = Cc,
            Bcc = Bcc,
            Subject = Subject,
            MailTemplate = MailTemplate,
            Header = "\"X-UUID\" " + DateTime.Now,
            HeaderCategory = HeaderCategory,
            Actiontype = Actiontype,
            KeyValueCollection = KeyValueCollection,
            AttachmentFileName = AttachmentFileName,
            MemoryStreamData = MemoryStreamData

如果您将此附件发送到某些邮件,它将联系到所需的申请人。试试这个可能有用。

于 2016-07-27T09:56:52.370 回答