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:

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

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. 
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:
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 .