1

I've a problem with gmail and my iCalendar, this is a simple iCalendar:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//www.notilus.com//Dimo Gestion Notilus//FR
CALSCALE:GREGORIAN
METHOD:REQUEST
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
DTSTART:20140619T080132Z
DTEND:20140619T090132Z
DTSTAMP:20140619T080132Z
ORGANIZER;CN=gonzo@work:mailto:gonzo@work
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=
 FALSE;CN=gonzo@home;X-NUM-GUESTS=0:mailto:gonzo@home
CREATED:20140619T080132Z
DESCRIPTION:Description of flying to Sligo
X-ALT-DESC;FMTTYPE=text/html:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//E
 N">\n<html>\n<body>\n<table border="1"><tr><td>\n<b>HTML</b> Description o
 f flying to Sligo\n</td></tr><tr><td>\n<ul><li>HTML has certain advantages
 </li></ul>\n</td></tr></table>\n</body>\n</html>
LAST-MODIFIED:20140619T080132Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Fly to Sligo
TRANSP:OPAQUE
UID:20140619T080132Z
END:VEVENT
END:VCALENDAR

Everything works if I attach it directly from gmail.

If I send from my website it doesn't.

here my code:

        using (var smtp = new SmtpClient())
        {
            var subject = "Confirm";
            var message = new MailMessage();
            message.To.Add(email);
            message.Subject = subject;

            var loCalendarType = new System.Net.Mime.ContentType();
            loCalendarType.MediaType = "text/calendar";
            loCalendarType.Parameters.Add("method", "REQUEST");
            loCalendarType.CharSet = @"""utf-8""";
            loCalendarType.Name = "event.ics";

            // Create message body parts
            var loCalendarView = AlternateView.CreateAlternateViewFromString(ical, loCalendarType);
            loCalendarView.TransferEncoding = System.Net.Mime.TransferEncoding.SevenBit;
            message.AlternateViews.Add(loCalendarView);

            // html
            message.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(html, Encoding.UTF8, System.Net.Mime.MediaTypeNames.Text.Html));

            smtp.Send(message);
        }

and this is the mime sent:

Delivered-To: xxx@yyy.zzz
Received: by 10.217.130.201 with SMTP id dv51csp438169web;
        Mon, 28 Jul 2014 03:31:02 -0700 (PDT)
X-Received: by 10.194.243.200 with SMTP id xa8mr47346727wjc.97.1406543462611;
        Mon, 28 Jul 2014 03:31:02 -0700 (PDT)
Return-Path: <yyy@gmail.com>
Received: from mail-wg0-x22c.google.com (mail-wg0-x22c.google.com [2a00:1450:400c:c00::22c])
        by mx.google.com with ESMTPS id s3si12813117wic.21.2014.07.28.03.31.02
        for <xxx@yyy.zzz>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Mon, 28 Jul 2014 03:31:02 -0700 (PDT)
Received-SPF: pass (google.com: domain of yyy@gmail.com designates 2a00:1450:400c:c00::22c as permitted sender) client-ip=2a00:1450:400c:c00::22c;
Authentication-Results: mx.google.com;
       spf=pass (google.com: domain of yyy@gmail.com designates 2a00:1450:400c:c00::22c as permitted sender) smtp.mail=yyy@gmail.com;
       dkim=pass header.i=@gmail.com;
       dmarc=pass (p=NONE dis=NONE) header.from=gmail.com
Received: by mail-wg0-f44.google.com with SMTP id m15so7011538wgh.3
        for <xxx@yyy.zzz>; Mon, 28 Jul 2014 03:31:02 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=message-id:date:mime-version:from:to:subject:content-type
         :content-transfer-encoding;
        bh=3k0Ih6rGieP/qB5GSChSJva4900sXW0sQFSUWVfWfbk=;
        b=YiK7r5XcO9llXe9ek1NVyZnSifa1qie9Twk7dwnTsa90+xOrRrDb4VI2VUnJv4QRHm
         kOE4s/SUiXZpzZBA5Eiqc2cygxn2H5i4+tVEx6bV0MggqG4A+YfbhEkR5aP2EzaOdOy5
         cozy5HDBpdYv1AFpcGIOrQz0vJs4OIUTi4lZTw57ViM/PwxzkCDcseOPezGWoFXjXCBK
         8p+IV4JWn/b7uuu/BK/ZNcawES72OgwkVx9aqL6m/gz3wJuF4Qh5orxcqWvO7L2T5R8M
         s+7hLBpHY8Os0U2EBa/wmihhdWj1RdnZlwntfdGTMJB5SnFD6J1WWFzlrzXzScHxVMsP
         +9UA==
X-Received: by 10.180.24.66 with SMTP id s2mr29127288wif.33.1406543460817;
        Mon, 28 Jul 2014 03:31:00 -0700 (PDT)
Return-Path: <yyy@gmail.com>
Received: from max-pc ([80.86.155.45])
        by mx.google.com with ESMTPSA id lh15sm29883233wic.10.2014.07.28.03.30.59
        for <xxx@yyy.zzz>
        (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128);
        Mon, 28 Jul 2014 03:30:59 -0700 (PDT)
Message-ID: <53d62663.afcdb40a.4c38.ffffd877@mx.google.com>
Date: Mon, 28 Jul 2014 03:30:59 -0700 (PDT)
X-Google-Original-Date: 28 Jul 2014 12:30:54 +0200
MIME-Version: 1.0
From: yyy@gmail.com
To: xxx@yyy.zzz
Subject: Confirm
Content-Type: text/calendar; method=REQUEST
Content-Transfer-Encoding: 7bit

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//www.notilus.com//Dimo Gestion Notilus//FR
CALSCALE:GREGORIAN
METHOD:REQUEST
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
DTSTART:20140619T080132Z
DTEND:20140619T090132Z
DTSTAMP:20140619T080132Z
ORGANIZER;CN=gonzo@work:mailto:gonzo@work
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=
 FALSE;CN=gonzo@home;X-NUM-GUESTS=0:mailto:gonzo@home
CREATED:20140619T080132Z
DESCRIPTION:Description of flying to Sligo
X-ALT-DESC;FMTTYPE=text/html:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//E
 N">\n<html>\n<body>\n<table border="1"><tr><td>\n<b>HTML</b> Description o
 f flying to Sligo\n</td></tr><tr><td>\n<ul><li>HTML has certain advantages
 </li></ul>\n</td></tr></table>\n</body>\n</html>
LAST-MODIFIED:20140619T080132Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Fly to Sligo
TRANSP:OPAQUE
UID:20140619T080132Z
END:VEVENT
END:VCALENDAR

I've read almost everything about it, but I really can't figure out what's wrong with my code. It's always displayed like an attachment and not like a appointment..

Bastianon Massimo
  • 1,710
  • 1
  • 16
  • 23

2 Answers2

1

Are you sure? Running your code, I get two basic errors. You need to provide a from address, and the utf8 line causes problems. Just comment it out. Those two things fixed, the resulting mail is correctly interpreted as an invitation by gmail.

The calendar, which is copied from this question I originally asked, is fine. Gmail is less picky than Outlook.

Community
  • 1
  • 1
bbsimonbb
  • 27,056
  • 15
  • 80
  • 110
1

just changed my smtp credential and everything works... 2 days of work.. wtf gmail

<mailSettings>
  <!-- NOT WORKING
<smtp from="xxx@gmail.com">
    <network host="smtp.gmail.com" port="587" enableSsl="true" userName="xxx@gmail.com" password="yyy" />
  </smtp>-->
  <smtp from="info@something.else">
    <network host="mail.something.else" userName="info@something.else" password="yyy" />
  </smtp>
</mailSettings>

My code:

using (var smtp = new SmtpClient())
{   
    var message = new MailMessage();

    message.To.Add(email);
    message.Subject = "Subject";

    // HTML
    message.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(html, Encoding.UTF8, System.Net.Mime.MediaTypeNames.Text.Html));

    // VCARD
    System.Net.Mime.ContentType loCalendarType = new System.Net.Mime.ContentType("text/calendar; method=REQUEST");
    AlternateView icalView = AlternateView.CreateAlternateViewFromString(ical, loCalendarType);
    icalView.TransferEncoding = TransferEncoding.Base64;
    message.AlternateViews.Add(icalView);

    smtp.Send(message);
}
Bastianon Massimo
  • 1,710
  • 1
  • 16
  • 23
  • I've checked and it doesn't work now - email received correctly, but meeting request is not recognized . Could you please check it again or probably share actual solution? – Eugene D. Gubenkov Dec 05 '14 at 20:10