在OutLook和Gmail中跟踪会议邀请响应

时间:2017-12-04 04:08:39

标签: c# asp.net asp.net-mvc asp.net-mvc-4 asp.net-web-api

我有条件要求我必须向邮件发送电子邮件邀请。用户可以接受并拒绝电子邮件中的响应。我已完成用户电子邮件邀请,并使用 .ics 文件在Gmail或Outlook中添加日历。以下是邀请电子邮件的代码

filePath = Path.Combine(HttpRuntime.AppDomainAppPath, "Email/calenderInvitation.ics");
                fileContent = System.IO.File.OpenText(filePath).ReadToEnd();
                fileContent = fileContent.Replace("#TO#", receiver);
                fileContent = fileContent.Replace("#FROM#", fromAddress.Address);
                fileContent = fileContent.Replace("#LOCATION#", eventVenue);
                fileContent = fileContent.Replace("#UID#", Guid.NewGuid().ToString().Replace("-", ""));
                fileContent = fileContent.Replace("#CREATED-AT#", Convert.ToDateTime(meetingDate).ToString(TimeFormat));
                fileContent = fileContent.Replace("#DTSTART#", Convert.ToDateTime(startTime).ToString(TimeFormat));
                fileContent = fileContent.Replace("#DTEND#", Convert.ToDateTime(finishTime).ToString(TimeFormat));


                MailMessage message = new MailMessage();
                message.From = new MailAddress(fromAddress.Address);
                message.To.Add(new MailAddress(receiver));
                message.Subject = string.Format("{0}  {1} @ {2} {3} {4} {5} - {6}", "Invitation: ", meetingTypeName,
                    Convert.ToDateTime(meetingDate).ToString("dddd"), Convert.ToDateTime(startTime).ToString("MMMM"),
                    Convert.ToDateTime(startTime).ToString("yyyy"), startTime,
                    finishTime);

                var iCalendarContentType = new ContentType("text/calendar; method=REQUEST");

                var calendarView = AlternateView.CreateAlternateViewFromString(fileContent, iCalendarContentType);
                calendarView.TransferEncoding = TransferEncoding.SevenBit;
                message.AlternateViews.Add(calendarView);
                smtp.Send(message);

以下是电子邮件的截图。

Email Inviatation

现在我想跟踪用户的响应,无论他们是否点击了ACCEPT / DECLINE

虽然研究发现了这个链接

https://msdn.microsoft.com/en-us/library/office/dd633669(v=exchg.80).aspx

然而,这将适用于outlook或Office 365.但我需要其他电子邮件的回复以及GMAIL等

这是.ics文件格式

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//A//B//EN
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
ORGANIZER;CN="Organizer":mailto:#FROM#
ATTENDEE;CN="Attendee";CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=
 NEEDS-ACTION;RSVP=TRUE:mailto:#TO#
DTSTART:#DTSTART#
DTEND:#DTEND#
LOCATION:#LOCATION#
SUMMARY: Invitation for Meeting
TRANSP:OPAQUE
SEQUENCE:0
UID:#UID#
DTSTAMP:#CREATED-AT#
CREATED:#CREATED-AT#
LAST-MODIFIED:#CREATED-AT#
DESCRIPTION:Test description\n
PRIORITY:5
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR

0 个答案:

没有答案