我想知道是否可以创建文件。 Ics用于已经预先填写的收件人电子邮件地址的新会议?是否可以将这些电子邮件地址作为参数发送?或许这根本不可能?
像这样:
以下是我的代码:#/ p>
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);
}
答案 0 :(得分:1)
您可以将以下与会者行添加到您的文件中:
Response.Write("ATTENDEE;CN=\"Toto Tutu\";RSVP=TRUE:mailto:toto.tutu@test.com");
答案 1 :(得分: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
如果您将此附件发送到某些邮件,它将覆盖所需的申请人。 试试这可能很有用。