简体   繁体   中英

Javascript: How to add event via button to Outlook Calendar

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?

The accepted answer didn't help me. So I will post what I found helpful as of December 2015.

http://calendar.live.com/calendar/calendar.aspx?rru=addevent

Parameters:

dtstart ( yyyymmddThhmmss )

Required. Specifies the event's start date and time. For example, 20110101T120000 represents January 1, 2011, at noon. Note that the portion specifying the event time (T120000) is optional.

dtend ( yyyymmddThhmmss )

Required. Specifies the event's end date and time. For example, 20110101T120000 represents January 1, 2011, at noon. Note that the portion specifying the event time (T120000) is optional.

summary ( Escaped string )

Optional. Specifies the event's title.

location ( Escaped string )

Optional. Specifies the event's location text.

 <a href="http://calendar.live.com/calendar/calendar.aspx?rru=addevent&dtstart=2015-12-07T20:00:00+00:00&dtend=2015-12-07T22:00:00+00:00&summary=Weekly Planning&location=BigCoHQ">Add to Outlook</a>

Source: msdn.microsoft.com

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.

 <a href="https://outlook.live.com/owa/?path=/calendar/view/Month&rru=addevent&startdt=20200213T000000Z&enddt=20200214T000000Z&subject=Test+Event&location=Dublin">Add to Outlook Calendar</a>

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}

The accepted answer didn't work for me. Here is the one which is working as of November 2022:

https://outlook.live.com/calendar/0/deeplink/compose?allday=false&body=This%20is%20event%20description&enddt=2022-11-29T15%3A15%3A00%2B00%3A00&path=%2Fcalendar%2Faction%2Fcompose&rru=addevent&startdt=2022-11-29T14%3A45%3A00%2B00%3A00&subject=TestEvent

You can generate it via this link as well: https://www.labnol.org/calendar/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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