简体   繁体   English

如何从 html 电子邮件打开默认日历应用程序?

[英]How to open default calendar app from html email?

I have in an html email a button.我在 html 电子邮件中有一个按钮。 When clicked, this button should add an event in the user's default calender app on their computer.单击此按钮时,应在用户计算机上的默认日历应用程序中添加一个事件。 Here's my code:这是我的代码:

<a href="webcal://domain.com/path/calendar.ics">

My question is: how to open the default app (not the web browser) of the user and add the event in their calendar using (or not using) an ics file.我的问题是:如何打开用户的默认应用程序(而不是网络浏览器)并使用(或不使用)ics 文件在他们的日历中添加事件。 If an app can't be launched, then a maybe a popup window asking which app to use to open the file and add the event.如果应用程序无法启动,那么可能会出现一个弹出窗口,询问使用哪个应用程序打开文件并添加事件。

Thank you for the help.感谢您的帮助。

There is no way to do this for the default calendar app on a user's device.对于用户设备上的默认日历应用程序,无法执行此操作。 - Especially not through the email itself. - 尤其不是通过电子邮件本身。

Here is a resource that may help you. 是一个可以帮助您的资源。

There are two parts to achieving this:实现这一目标有两个部分:

  1. as Dr.Tenma says - on the user side, one cannot enforce how the user opens any file type.正如天马博士所说 - 在用户方面,不能强制用户打开任何文件类型的方式。 What application is opened when a link to your url is clicked depends on their browser and/or mail and/or system settings.单击指向您 url 的链接时打开的应用程序取决于他们的浏览器和/或邮件和/或系统设置。 For example: In firefox my settings say to open a.ics file in notepad++例如:在 Firefox 中,我的设置说在记事本++中打开 a.ics 文件

  2. The url/file itself must contain valid ics as per the RFC5545 specification, the mimetype in the header must be text/calendar.根据 RFC5545 规范,url/文件本身必须包含有效的 ics,标题中的 mimetype 必须是 text/calendar。 I would also suggest using the official protocol of http/s.我还建议使用 http/s 的官方协议。 Webcal is an unofficial apple protocol. Webcal 是一个非官方的苹果协议。 Many applications will cope with it if everything else is correct, but it is not the official protocol, not registered with IANA.如果其他一切都正确,许多应用程序会处理它,但它不是官方协议,未在 IANA 注册。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM