Why doesn't GMail recognize a meeting request sent from code?

I am wondering how to send a meeting invitation so that GMail recognizes it correctly?

If you try to send the iCalendar meeting request definition below as an alternative view using the familiar code (also shown below) using the MailMessage object for GMail, this will result in an unrecognized meeting request:

enter image description here

But mail with exactly the same meeting request sent via the GMail interface results in a recognized meeting request! Incomprehensible.

enter image description here

Does anyone know what “magic” I am missing?

It's nice to notice that Outlook correctly recognizes exactly the same meeting request sent by this code. enter image description here

Code for sending meeting request mail:

 class Program { static string From = " sender@example.com "; static string TimeFormat = "yyyyMMdd\\THHmmss\\Z"; static string To = " target@example.dom "; static void Main(string[] args) { string content = ReadFile("event-template.ics"); content = content.Replace("#TO#", To); content = content.Replace("#FROM#", From); content = content.Replace("#UID#", Guid.NewGuid().ToString().Replace("-", "")); content = content.Replace("#CREATED-AT#", DateTime.UtcNow.AddDays(-1).ToString(TimeFormat)); content = content.Replace("#DTSTART#", DateTime.UtcNow.AddDays(1).ToString(TimeFormat)); content = content.Replace("#DTEND#", DateTime.UtcNow.AddDays(1).AddHours(1).ToString(TimeFormat)); MailMessage message = new MailMessage(); message.From = new MailAddress(From); message.To.Add(new MailAddress(To)); message.Subject = "Meeting Request from Code!"; var iCalendarContentType = new ContentType("text/calendar; method=REQUEST"); var calendarView = AlternateView.CreateAlternateViewFromString(content, iCalendarContentType); calendarView.TransferEncoding = TransferEncoding.SevenBit; message.AlternateViews.Add(calendarView); using (var smtp = new SmtpClient()) { smtp.Send(message); } } public static string ReadFile(string fileName) { using (StreamReader r = new StreamReader(fileName)) { return r.ReadToEnd(); } } } 

ICalendar template definition:

 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 test 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 

UPD Email source generated by code and received by GMail (not recognized by GMail as a meeting invitation): http://pastebin.com/MCU6P16Y .

GMail email source forwarded (recognized correspondent): http://pastebin.com/zfbbj9Gg

IMPORTANT UPDATE. Just changing the target from my email ( <my>@gmail.com ) to my colleague ( <colleague>@gmail.com ) and starts to recognize correctly ! Now this definitely looks like a problem with GMail. (I am sending an email address from an address that is different from the target, of course)

UPDATE. Found exactly the same problem in the GMail support forum: Error: Gmail does not recognize .ics calendar invitations attached to incoming messages . The question, dated June 2011, was published in July 2011. I created a new topic there: GMail cannot recognize the * .ics application as an invitation to meetings .

+6
source share
2 answers

It seems that the problem is not that GMAIL recognizes the meeting request, but with problems displaying it. I was worried about the same problem.

It was “fixed” after I changed the GMAIL display language to “English (US)” in the “Settings” menu.

So this is definitely a mistake.

+2
source

If you use C #, I managed to get this working environment of Outlook, gmail, outlook 2016.

What you need to do is add an alternative view, this does not work if you have several views, but works for your example above.

Alternative view below:

  var ct = new ContentType("text/calendar"); if (ct.Parameters != null) { ct.Parameters.Add("method", "REQUEST"); ct.Parameters.Add("charSet", "utf-8"); var avCal = AlternateView.CreateAlternateViewFromString(calendarAppt.ToString(), ct); avCal.TransferEncoding = TransferEncoding.Base64; mail.AlternateViews.Add(avCal); } 
0
source

Source: https://habr.com/ru/post/979226/


All Articles