我们的ASP.NET应用程序创建VCALENDAR邀请作为多视线电子邮件的一部分,该电子邮件直接进入Invitee的日历,还提供了一个普通的文本视图。 无论我们使用哪种设置,Outlook呈现RSVP功能都很好。
由于我们没有在代码中“接收”响应,所以我们试图防止用户使用降低/接受功能。VCAL示例针对ONLINE验证器验证了,并且我(尽最大努力)消化了标准,但看不到任何明显的问题:
BEGIN:VCALENDAR
VERSION:2.0
METHOD:REQUEST
PRODID:-//MyApp//EN
BEGIN:VEVENT
DTSTAMP:20250206T135450Z
DTSTART:20250207T100000Z
SUMMARY:First Aid
UID:1b5f358a-829a-4767-a236-b706592a0ad8
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;RSVP=FALSE;CN="[email protected]":MAILTO:[email protected]
ACTION;RSVP=FALSE;CN="Jane Doe":MAILTO:[email protected]
ORGANIZER;CN="Jane Doe":MAILTO:[email protected]
LOCATION:
DTEND:20250207T120000Z
DESCRIPTION:
CREATED:20250206T135450Z
LAST-MODIFIED:20250206T135450Z
STATUS:CONFIRMED
TRANSP:OPAQUE
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:REMINDER
TRIGGER:-PT30M
END:VALARM
END:VEVENT
END:VCALENDAR
有人可以建议如何停止Outlook这样做,因为我认为我们会用
RSVP=FALSE
和
PARTSTAT=ACCEPTED
?
update
copilot建议切换到
METHOD=PUBLISH
当我测试了发送这些iCalendar请求时,我注意到一些有趣的东西可以用作“某种hack”。
当您是“会议的组织者”时,您不需要回应。这是给我“您是组织者,因此您无需反应”的代码:
using System.Net.Mail;
using System.Net.Mime;
using System.Text;
var from = "sender@mailserver";
var subj = "TEST EMAIL " + DateTime.Now.ToString("G");
var body = "We do not handle accepting/temporary accepting/decling the appointment it is automatically accepted.";
var recipient = "recipient@mailserver";
var recipientName = "Name of Recipient";
MailMessage msg = new MailMessage();
msg.From = new MailAddress(from);
msg.To.Add(recipient);
msg.Subject = subj;
AlternateView avBody = AlternateView.CreateAlternateViewFromString(body, Encoding.UTF8, MediaTypeNames.Text.Html);
msg.AlternateViews.Add(avBody);
// Generate Calendar Invite ---------------------------------------------------
StringBuilder str = new StringBuilder();
str.AppendLine("BEGIN:VCALENDAR");
str.AppendLine("PRODID:-//Schedule a Meeting");
str.AppendLine("VERSION:2.0");
str.AppendLine("METHOD:REQUEST");
str.AppendLine("BEGIN:VEVENT");
str.AppendLine(string.Format("DTSTART:{0:yyyyMMddTHHmmssZ}", DateTime.Now.AddMinutes(+330)));
str.AppendLine(string.Format("DTSTAMP:{0:yyyyMMddTHHmmssZ}", DateTime.UtcNow));
str.AppendLine(string.Format("DTEND:{0:yyyyMMddTHHmmssZ}", DateTime.Now.AddMinutes(+660)));
str.AppendLine("LOCATION: " + "online TEAMS LINK");
str.AppendLine(string.Format("UID:{0}", Guid.NewGuid()));
str.AppendLine(string.Format("DESCRIPTION:{0}", msg.Body));
str.AppendLine(string.Format("X-ALT-DESC;FMTTYPE=text/html:{0}", msg.Body));
str.AppendLine(string.Format("SUMMARY:{0}", msg.Subject));
str.AppendLine(string.Format("ORGANIZER:MAILTO:{0}", msg.To[0].Address));
str.AppendLine(string.Format("ATTENDEE;CN=\"{0}\";RSVP=FALSE:mailto:{1}", msg.To[0].DisplayName, msg.To[0].Address));
str.AppendLine("BEGIN:VALARM");
str.AppendLine("TRIGGER:-PT15M");
str.AppendLine($"ACTION;RSVP=FALSE;CN=\"{recipientName}\":MAILTO:{recipient}");
str.AppendLine("DESCRIPTION:Reminder");
str.AppendLine("END:VALARM");
str.AppendLine("END:VEVENT");
str.AppendLine("END:VCALENDAR");
// Attach Calendar Invite ------------------------------------------------------
byte[] byteArray = Encoding.ASCII.GetBytes(str.ToString());
MemoryStream stream = new MemoryStream(byteArray);
Attachment attach = new Attachment(stream, "invite.ics");
attach.TransferEncoding = TransferEncoding.QuotedPrintable;
msg.Attachments.Add(attach);
ContentType contype = new ContentType("text/calendar");
contype.CharSet = "UTF-8";
contype.Parameters.Add("method", "REQUEST");
contype.Parameters.Add("name", "invite.ics");
AlternateView avCal = AlternateView.CreateAlternateViewFromString(str.ToString(), contype);
avCal.TransferEncoding = TransferEncoding.QuotedPrintable;
msg.AlternateViews.Add(avCal);
//Now sending a mail with attachment ICS file. ----------------------------------
SmtpClient smtpclient = new SmtpClient();
smtpclient.Host = "mailserver";
smtpclient.EnableSsl = true;
smtpclient.Port = 587;
smtpclient.Credentials = new System.Net.NetworkCredential("username", "password");
smtpclient.Send(msg);
Console.WriteLine("Email Sent");
Console.ReadLine();