15

I hope this question is OK to ask here, given that it could replace my usage for Google Calendar API I think it should be OK.

https://stackoverflow.com/help/on-topic

When you get an email about an event like a flight, concert, or restaurant reservation, it's added to your calendar automatically.

https://support.google.com/calendar/answer/6084018?co=GENIE.Platform%3DDesktop&hl=en

I think this is a really neat feature but I would like to know If I can create an email that will automatically show up in my calendar myself. I'm currently using the Calendar API, Google.Apis.Calendar.v3, but if I could get this to work my application would not need to handle credentials anymore which would be really great.

Cases where the email won't show up according to support page:

Events won't show up if the email was:

  • Sent to a mailing list
  • Sent to you by cc
  • Redirected from another email account

Events are only added if they are in confirmation emails from businesses about:

  • Flights
  • Hotels
  • Restaurants
  • Ticketed events like movies and concerts

I have been reading up on Events from Gmail and created the sample below.

https://developers.google.com/gmail/markup/google-calendar

https://developers.google.com/gmail/markup/getting-started

https://developers.google.com/gmail/markup/reference/event-reservation

<html>
<body>
    <script type="application/ld+json">
        {
        "@context": "http://schema.org",
        "@type": "EventReservation",
        "reservationNumber": "E123456789",
        "reservationStatus": "http://schema.org/Confirmed",
        "underName": {
        "@type": "Person",
        "name": "Oscar Andersson"
        },
        "reservationFor": {
        "@type": "Event",
        "name": "Foo Fighters Concert",
        "performer": {
        "@type": "Organization",
        "name": "The Foo Fighters",
        "image": "http://www.amprocktv.com/wp-content/uploads/2027/01/foo-fighters-1-680x383.jpg"
        },
        "startDate": "2019-05-08T19:30:00-01:00",
        "endDate": "2019-05-08T23:00:00-01:00",
        "location": {
        "@type": "Place",
        "name": "AT&T Park",
        "address": {
        "@type": "PostalAddress",
        "streetAddress": "AT&T Park",
        "addressLocality": "San Francisco",
        "addressRegion": "CA",
        "postalCode": "94107",
        "addressCountry": "US"
        }
        }
        },
        "ticketToken": "qrCode:AB34",
        "ticketNumber": "abc123",
        "numSeats": "1",
        "modifiedTime": "2019-05-07T15:15:00-01:00",
        "modifyReservationUrl": "http://united.com/modifyreservation.html"
        }
    </script>

    <p>
        Dear Oscar, thanks for booking your Google I/O ticket with us.
    </p>
    <p>
        BOOKING DETAILS<br />
        Reservation number: IO12345<br />
        Order for: Oscar Andersson<br />
        Event: Google I/O 2013<br />
        Start time: May 15th 2013 8:00am PST<br />
        Venue: Moscone Center, 800 Howard St., San Francisco, CA 94103<br />
    </p>
</body>
</html>

I have validated the markup with Email Markup Tester from Google and it says No errors detected. Then I imported the HTML above from Notepad++ to Outlook via Run -> Send via Outlook and sent it to my Gmail. I received the email but the Calendar event was not present.

https://www.google.com/webmasters/markup-tester/

According to their documentation All schemas you send to yourself (from x@gmail.com to x@gmail.com) will be displayed in Google products. but I can't see the event.

https://developers.google.com/gmail/markup/registering-with-google

I have tried creating my own program to send the email via Gmail servers to myself but the events still don't show. Tried copying a lot of the events mentioned on their guides and reference page.

var emailAddress = new MailAddress("myGmail@gmail.com", "Ogglas");

SmtpClient smtpClient = new SmtpClient();
smtpClient.Host = "smtp.gmail.com";
smtpClient.Port = 587;
smtpClient.EnableSsl = true;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new NetworkCredential("myGmail@gmail.com", "mySuperSecurePassword789&");

MailMessage mailMessage = new MailMessage();
mailMessage.From = emailAddress;
mailMessage.To.Add(emailAddress);
mailMessage.Subject = "Concert test";
mailMessage.IsBodyHtml = true;

var currentPath = Directory.GetCurrentDirectory();
var htmlEmail = File.ReadAllText(currentPath + "\\Email.html");
mailMessage.Body = htmlEmail;

smtpClient.Send(mailMessage);

Example from a flight how I would like it to look:

Gmail:

enter image description here

Calendar:

enter image description here

Example from booking.com

enter image description here

Has anyone here managed to get this working?

Ogglas
  • 62,132
  • 37
  • 328
  • 418
  • 1
    `Events from Gmail` should be enabled by default, but check your calendar settings to ensure that it actually is. Also, please note - ***"Events from Gmail aren't available for Government accounts, accounts with data location restrictions, or Google Accounts that don't have Gmail"***. – TheAddonDepot May 07 '19 at 18:55
  • 2
    Also keep in mind that ld+json isn't supported by all email services, so it could be that Outlook is sanitizing your html or treating it as raw text. – TheAddonDepot May 07 '19 at 19:02
  • One more thing, ld+json is but one of 2 email markup formats available in Gmail. You can try using the other format (ie. `Microdata`) instead. – TheAddonDepot May 07 '19 at 19:09
  • @DimuDesigns Works with flights and hotels from larger corporations so it is enabled as you can see in the screenshots. Looked at the raw html in `.eml` and sure enough the script was gone from Outlook email. I then tried with https://putsmail.com/ and the script got included but nothing showed up anyway. Gonna try to write som code and use my own mailserver and see if it helps. Tried with `Microdata` as well but it did not work unfortunately. – Ogglas May 08 '19 at 07:28
  • I have hit the same roadblock and could not see a way out. I am using PowerShell to send email. I practically do not see any difference in the Original message content between those which parse the event information and those which do not. I am testing with my own email id which is a regular gmail account id. I wonder why google is not helping in this front as well. – Siva Senthil Aug 19 '19 at 17:34
  • @SivaSenthil Same here, I hope some Google Official will pick this up. Especially since their support says: `You may ask questions about Gmail schemas supported on Stack Overflow. Google engineers monitor and answer against the tag google-schemas, so please use this tag when asking questions. We aim to answer all questions in a reasonable period of time.` https://developers.google.com/gmail/markup/support – Ogglas Aug 20 '19 at 06:00
  • So... I'm assuming this has not yet been answered by any Google Official. @Ogglas, have you been able to find some light on this issue? I'm currently trying to accomplish the same thing as you. – Graph Jan 07 '21 at 15:17
  • @Graph Nope I ended up using my current solution, Google Calendar API. https://developers.google.com/calendar/quickstart/dotnet – Ogglas Jan 07 '21 at 15:23
  • @Ogglas Thanks for the answer – Graph Jan 13 '21 at 17:29

0 Answers0