以编程方式将ics会议邀请添加到Google日历

问题描述 投票:1回答:1

我正在使用c#进行ic会议邀请。当我们向Outlook邮件发送邀请邮件时,它会自动在Outlook日历中添加会议邀请,但是在我们单击gmail中的yes接受邀请之前,它不会自动在Google日历中添加邀请。我想自动添加会议邀请Google日历,如何使用c#做到这一点?

在Outlook中有效:(这里我没有点击是,在收到电子邮件后,会议邀请仍添加到Outlook中)outlook

这是我的代码:

string startTime1 = TimeZoneInfo.ConvertTimeToUtc(Convert.ToDateTime(data.START_TIME)).ToString("yyyyMMddTHHmmssZ");
string endTime1 = TimeZoneInfo.ConvertTimeToUtc(Convert.ToDateTime(data.END_TIME)).ToString("yyyyMMddTHHmmssZ");

SmtpClient sc = SmtpSettings();
MailMessage msg = new MailMessage();

msg.From = new MailAddress("[email protected]", "Screen Detailing");
msg.To.Add(new MailAddress(data.TO_EMAIL));              

msg.Subject = data.SUBJECT;
msg.Body = "Zoom URL: " + data.ZOOM_URL + "n/ Zoom Pwd: " + data.ZOOM_PWD; //emailbody

StringBuilder str = new StringBuilder();
str.AppendLine("BEGIN:VCALENDAR");

//PRODID: identifier for the product that created the Calendar object
str.AppendLine("PRODID:-//ABC Company//Outlook MIMEDIR//EN");
str.AppendLine("VERSION:2.0");
str.AppendLine("METHOD:REQUEST");

str.AppendLine("BEGIN:VEVENT");

str.AppendLine(string.Format("DTSTART:{0:yyyyMMddTHHmmssZ}", startTime1));
str.AppendLine(string.Format("DTSTAMP:{0:yyyyMMddTHHmmssZ}", DateTime.Now));
str.AppendLine(string.Format("DTEND:{0:yyyyMMddTHHmmssZ}", endTime1));
str.AppendLine(string.Format("LOCATION: {0}", "Location"));

// UID should be unique.
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("STATUS:CONFIRMED");
str.AppendLine("BEGIN:VALARM");
str.AppendLine("TRIGGER:-PT15M");
str.AppendLine("ACTION:Accept");
str.AppendLine("DESCRIPTION:Reminder");
str.AppendLine("X-MICROSOFT-CDO-BUSYSTATUS:BUSY");
str.AppendLine("END:VALARM");
str.AppendLine("END:VEVENT");

str.AppendLine(string.Format("ORGANIZER:MAILTO:{0}", msg.From.Address));
str.AppendLine(string.Format("ATTENDEE;CN=\"{0}\";RSVP=TRUE:mailto:{1}", msg.To[0].DisplayName, msg.To[0].Address));

str.AppendLine("END:VCALENDAR");
System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType("text/calendar");
ct.Parameters.Add("method", "REQUEST");
ct.Parameters.Add("name", "meeting.ics");
AlternateView avCal = AlternateView.CreateAlternateViewFromString(str.ToString(), ct);
msg.AlternateViews.Add(avCal);
sc.Send(msg);

是否有任何脚本或代码可将会议邀请自动添加到设备上的任何日历?即Googl,ios等。

c# outlook sendmail google-calendar-recurring-events meeting-request
1个回答
0
投票

这对我有用。

            sb.AppendLine("BEGIN:VCALENDAR");
            sb.AppendLine("PRODID:-//app//ES");
            sb.AppendLine("BEGIN:VEVENT");
            sb.AppendLine("DTSTART:" + calendar.IcsDateStart.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"));
            sb.AppendLine("DTEND:" + calendar.IcsDateEnd.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"));
            sb.AppendLine("LOCATION:" + calendar.IcsLocation);
            sb.AppendLine("DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" + calendar.IcsDescription);
            sb.AppendLine("GEO:" + calendar.IcsLatitude + ";" + calendar.IcsLongitude + "");
            sb.AppendLine("UID:" + calendar.IcsId + "");
            sb.AppendLine(string.Format("ORGANIZER:MAILTO:{0}", ""));
            sb.AppendLine("SUMMARY:" + calendar.IcsSummary);
            sb.AppendLine("PRIORITY:3");
            sb.AppendLine("END:VEVENT");
            sb.AppendLine("END:VCALENDAR");
            return sb;

无论您是否要参加此活动,谷歌始终都会要求。

© www.soinside.com 2019 - 2024. All rights reserved.