Javascript:如何通过按钮将事件添加到 Outlook 日历
我目前编写了一个有效的 vbscript 实现:
<code>
<script language="VBScript">
<!--
sub MakeAppointment(MySubject, MyLocation, MyStart, MyEnd, MyMessage)
Dim objOutlook
Dim itmCalendar
Set objOutlook = CreateObject("Outlook.application")
Set itmCalendar = objOutlook.CreateItem(1)
itmCalendar.Subject = MySubject
itmCalendar.Location = MyLocation
itmCalendar.Start = MyStart
itmCalendar.End = MyEnd
itmCalendar.Body = MyMessage
itmCalendar.Save
Msgbox "Appointment has been added to your Outlook Calendar!", 0, MyStart
Set itmCalendar = Nothing
Set objOutlook = Nothing
end sub
-->
</script>
<script language="VBScript">
<!--
Sub btnAdd_onclick()
MySubject="All your base are belong to us"
MyLocation="Japan"
MyStart="05/19/2011 07:00"
MyEnd="05/19/2011 08:00"
MyMessage = "This is a English review course." & vbcrlf
MyMessage = MyMessage & "" & vbcrlf
MyMessage = MyMessage & "" & vbcrlf
MyMessage = MyMessage & "" & vbcrlf
MakeAppointment MySubject, MyLocation, MyStart, MyEnd, MyMessage
End Sub
-->
</script>
</code>
我需要一些帮助来了解如何为 Javascript 重写它,因为我正在编写的另一个 SharePoint 网站正在使用 Javascript 作为其默认验证脚本语言。有可能吗?有任何可能的资源链接来实现这一目标吗?
I currently have a working vbscript implementation written:
<code>
<script language="VBScript">
<!--
sub MakeAppointment(MySubject, MyLocation, MyStart, MyEnd, MyMessage)
Dim objOutlook
Dim itmCalendar
Set objOutlook = CreateObject("Outlook.application")
Set itmCalendar = objOutlook.CreateItem(1)
itmCalendar.Subject = MySubject
itmCalendar.Location = MyLocation
itmCalendar.Start = MyStart
itmCalendar.End = MyEnd
itmCalendar.Body = MyMessage
itmCalendar.Save
Msgbox "Appointment has been added to your Outlook Calendar!", 0, MyStart
Set itmCalendar = Nothing
Set objOutlook = Nothing
end sub
-->
</script>
<script language="VBScript">
<!--
Sub btnAdd_onclick()
MySubject="All your base are belong to us"
MyLocation="Japan"
MyStart="05/19/2011 07:00"
MyEnd="05/19/2011 08:00"
MyMessage = "This is a English review course." & vbcrlf
MyMessage = MyMessage & "" & vbcrlf
MyMessage = MyMessage & "" & vbcrlf
MyMessage = MyMessage & "" & vbcrlf
MakeAppointment MySubject, MyLocation, MyStart, MyEnd, MyMessage
End Sub
-->
</script>
</code>
I am in need of some help on how to re-write this for Javascript as another SharePoint site I am writing for is using Javascript as its default validation script language. Is it even possible? Any links to possible resources on getting this accomplished?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
接受的答案对我没有帮助。因此,我将发布截至 2015 年 12 月我发现有帮助的内容。
参数:
dtstart (yyyymmddThhmmss)
dtend (yyyymmddThhmmss)
摘要(转义字符串)
位置(转义字符串)
来源:msdn.microsoft.com
The accepted answer didn't help me. So I will post what I found helpful as of December 2015.
Parameters:
dtstart (yyyymmddThhmmss)
dtend (yyyymmddThhmmss)
summary (Escaped string)
location (Escaped string)
Source: msdn.microsoft.com
我设法通过将事件信息直接填充到 Outlook 链接来解决此问题,因此它会将您重定向到一个模式,您可以在将事件信息保存到日历之前验证该模式是否正确。
以下链接示例包含您想要从对象填充信息的参数
https://outlook .live.com/owa/?path=/calendar/view/Month&rru=addevent&startdt=${eventStart}&enddt=${eventEnd}&subject=${eventName}&location=${eventLocation }&body=${eventDescription}
I managed to solve this by populating the event information directly to the outlook link, so it'll redirect you to a modal that you can verify if the event information is correct before saving it to your calendar.
The following link example contains the parameters in case you want to populate information from an object
https://outlook.live.com/owa/?path=/calendar/view/Month&rru=addevent&startdt=${eventStart}&enddt=${eventEnd}&subject=${eventName}&location=${eventLocation}&body=${eventDescription}
接受的答案对我不起作用。这是截至 2022 年 11 月有效的版本:
您也可以通过此链接生成它:https:// /www.labnol.org/calendar/
The accepted answer didn't work for me. Here is the one which is working as of November 2022:
You can generate it via this link as well: https://www.labnol.org/calendar/
为了获得更具可读性和可用性的代码,我分隔了日历的字段。日期需要像
'2023-08-07T01:00:00.000Z'
这样的 ISO 格式,其他所有内容都只是一个字符串。如果您只想要最终的href,可以使用另一个答案 https://www.labnol.org/calendar/,这将生成您可以使用的最终网址。
之后,您只需在锚标记或您想要使用的任何元素中设置 href,例如
document.querySelector("#outlook-link").href = href"
In order to have a more readable and usable code I separated the fields for the calendar. The date needs an ISO format like
'2023-08-07T01:00:00.000Z'
, and everything else is just a string.If you only want the final href, you can use the link provided in another answer https://www.labnol.org/calendar/, which will generate the final url you can use.
After this you can just set the href in your anchor tag or whatever element you want to use like
document.querySelector("#outlook-link").href = href"