提问人:Ogglas 提问时间:5/7/2019 最后编辑:Ogglas 更新时间:1/19/2021 访问量:3749
Gmail 自动解析并添加日历活动的电子邮件
Email that is automatically parsed by Gmail and adds a Calendar event
问:
我希望这个问题可以在这里问,因为它可以取代我对 Google Calendar API 的使用,我认为它应该没问题。
https://stackoverflow.com/help/on-topic
当您收到有关航班、音乐会或餐厅预订等活动的电子邮件时,系统会自动将其添加到您的日历中。
https://support.google.com/calendar/answer/6084018?co=GENIE.Platform%3DDesktop&hl=en
我认为这是一个非常简洁的功能,但我想知道我是否可以创建一个电子邮件,该电子邮件将自动显示在我的日历中。我目前正在使用日历 API, Google.Apis.Calendar.v3,但如果我能让它工作,我的应用程序将不再需要处理凭据,这将是非常棒的。
根据支持页面,电子邮件不会显示的情况:
如果电子邮件是:
- 发送到邮件列表
- 抄送发送给您
- 重定向自其他电子邮件帐户
只有当事件出现在商家发送的确认电子邮件中时,才会添加这些事件:
- 航班
- 酒店
- 餐馆
- 售票活动,如电影和音乐会
我一直在阅读并创建了下面的示例。Events from Gmail
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>
我已经验证了来自 Google 的标记,它说.然后,我通过Run -> Send via Outlook将上面的HTML从Notepad ++导入Outlook,并将其发送到我的Gmail。我收到了电子邮件,但日历活动不存在。Email Markup Tester
No errors detected
https://www.google.com/webmasters/markup-tester/
根据他们的文件,但我看不到该事件。All schemas you send to yourself (from x@gmail.com to [email protected]) will be displayed in Google products.
https://developers.google.com/gmail/markup/registering-with-google
我尝试创建自己的程序以通过Gmail服务器将电子邮件发送给自己,但事件仍然没有显示。尝试复制他们的指南和参考页面上提到的许多事件。
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);
我希望它看起来是什么样子的航班示例:
Gmail的:
日历:
booking.com 示例
这里有人设法让它工作吗?
答: 暂无答案
评论
Events from Gmail
默认情况下应启用,但请检查您的日历设置以确保它确实处于启用状态。另外,请注意 - “来自 Gmail 的事件不适用于政府帐号、有数据位置限制的帐号或没有 Gmail 的 Google 帐号”。Microdata
.eml
Microdata