Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why GMail does not recognize meeting request sent from code?

I'm wondering how to send meeting request to allow GMail correctly recognize it?

If you try to send iCalendar meeting request definition given bellow as an alternative view using habitual code (also given bellow) via MailMessage object to GMail it will be resulted in not recognized meeting request:

enter image description here

But the mail with exactly the same meeting request sent via GMail UI results in recognized meeting request! Puzzling.

enter image description here

Does anybody know what "magic" I'm missing?

Good to notice that Outlook correctly recognizes exactly the same meeting request sent by given code. enter image description here

The code to send mail with meeting request:

class Program
{
    static string From = "[email protected]";
    static string TimeFormat = "yyyyMMdd\\THHmmss\\Z";
    static string To = "[email protected]";

    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. The source of email generated by code and received by GMail (not recognized by GMail as a meeting request): http://pastebin.com/MCU6P16Y.

The source of email composed by GMail during forwarding (recognized correclty): http://pastebin.com/zfbbj9Gg

IMPORTANT UPDATE. Just changing target from my email (<my>@gmail.com) to my colleague's one (<colleague>@gmail.com) and it starts to recognize properly! Now it definitely looks like GMail issue. (I'm sending email from the address that differs from target, sure)

UPDATE. Found exactly the same issue in GMail support forum: Bug: Gmail fails to recognize .ics calendar invitations attached to incoming messages. The issue dated by Jun, 2011 and reported as fixed to Jul, 2011. I've created new topic there: GMail fails to recognize *.ics attachment as a meeting request.

like image 665
Eugene D. Gubenkov Avatar asked Dec 06 '14 17:12

Eugene D. Gubenkov


1 Answers

It seems that the problem is not with GMAIL recognizing the meeting request, but with problems displaying it. I was bugged by the same problem.

It was "fixed" after I changed GMAIL display language to "English (US)" from Settings menu.

So it is definitely a bug.

like image 150
Toomas Mõttus Avatar answered Oct 10 '22 19:10

Toomas Mõttus