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 [email protected] to [email protected]) 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("[email protected]", "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("[email protected]", "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:
Calendar:
Example from booking.com
Has anyone here managed to get this working?
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". – GreersonMicrodata
) instead. – Greerson.eml
and sure enough the script was gone from Outlook email. I then tried with 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 withMicrodata
as well but it did not work unfortunately. – MayhewYou 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.
developers.google.com/gmail/markup/support – Mayhew