admin管理员组

文章数量:1318998

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 acplished?

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 acplished?

Share Improve this question edited Mar 11, 2016 at 14:42 Ivanka Todorova 10.2k17 gold badges70 silver badges106 bronze badges asked May 18, 2011 at 19:09 SD.SD. 3,10911 gold badges27 silver badges21 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 3

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

http://calendar.live./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./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.

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./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./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./calendar/0/deeplink/pose?allday=false&body=This%20is%20event%20description&enddt=2022-11-29T15%3A15%3A00%2B00%3A00&path=%2Fcalendar%2Faction%2Fpose&rru=addevent&startdt=2022-11-29T14%3A45%3A00%2B00%3A00&subject=TestEvent

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

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/calendar/, which will generate the final url you can use.

const event = {
  title: "Event title",
  description: "This is the description",
  startTime: new Date("Aug 06 2023 19:00:00"),
  endTime: new Date("Aug 06 2023 22:00:00"),
  address: "123 main street",
}

let href = encodeURI(
  [
    "https://outlook.live./calendar/0/action/pose",
    "?allday=false",
    "&body=" + event.description,
    "&enddt=" + event.endTime.toISOString(),
    "&location=" + event.address,
    "&path=%2Fcalendar%2Faction%2Fpose",
    "&rru=addevent",
    "&startdt=" + event.startTime.toISOString(),
    "&subject=" + event.title,
  ].join("")
);

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"

本文标签: sharepointJavascript How to add event via button to Outlook CalendarStack Overflow