我在共享点页面上有一个日历,如果我们可以同步要在日历上显示的电子邮件地址,则客户会喜欢它。
使用网络应用程序和我在Share Point 2013中设置日历。
我不知道如何做到这一点,并且在日历覆盖设置中乱七八糟但无法使其正常工作。
有什么建议吗?
答案 0 :(得分:0)
您可以使用Outlook Rest API在SharePoint页面中同步Outlook日历。
关注Get Outlook Events以获取展望日历中的所有活动。
请参阅我的解决方法,在Sharepoint页面的Jquery完整日历中绑定Outlook日历事件。
<link rel="stylesheet" type="text/css" href="/sites/xxx/SiteAssets/fullcalendar.css">
<script src='/sites/xxx/SiteAssets/moment.min.js'></script>
<script src="/sites/xxx/SiteAssets/jquery-1.12.3.min.js"></script>
<script src='/sites/xxx/SiteAssets/jquery.min.js'></script>
<script src='/sites/xxx/SiteAssets/fullcalendar.js'></script>
<script type="text/javascript">
var even = new Array();
$(document).ready(function () {
$.support.cors = true;
$.getScript('/sites/xxx/SiteAssets/fullcalendar.js', function () {
$.getScript('/sites/xxx/SiteAssets/moment.min.js', GetAuthorizeCode);
}
);
});
function GetAuthorizeCode() {
var initialUri = window.location.href;
if (initialUri.indexOf('code') == -1) {
var url = "https://login.windows.net/common/oauth2/authorize?response_type=code&client_id=[client_id of your application]&redirect_uri=https://xxx.sharepoint.com/sites/xxx/Site%20Pages/Test.aspx&resource=https:%2f%2foutlook.office365.com%2f&state=5fdfd60b-8457-4536-b20f-fcb658d19458";
window.location.href = url;
}
else {
var codeVal = getQueryStringParameter("code");
var accessToken = getAccessToken(codeVal);
}
}
function getQueryStringParameter(param) {
var params = document.URL.split("?")[1].split("&");
var strParams = "";
for (var i = 0; i < params.length; i = i + 1) {
var singleParam = params[i].split("=");
if (singleParam[0] == param) {
return singleParam[1];
}
}
}
function getAccessToken(code) {
$.ajax({
type: "Get",
url: "Url to get AccessToken",
dataType: "json",
success: function (data) {
debugger;
var accesstoken= data["AccessToken"];
var events = GetEvents(accesstoken);
},
error: function (httpReq, status, exception) {
debugger;
return "";
}
});
}
function GetEvents(token) {
debugger;
var call = $.ajax({
url: "https://outlook.office.com/api/v2.0/me/events",
type: "GET",
dataType: "json",
headers: {
Accept: "application/json;odata.metadata=minimal;odata.streaming=true",
'Authorization': "Bearer " + token
},
success: function (data) {
debugger;
for (var i = 0; i < data.value.length ; i++) {
even.push({
title: data.value[i].Subject,
start: data.value[i].Start.DateTime,
url: data.value[i].WebLink,
end:data.value[i].End.DateTime
});
}
$('#calendar').fullCalendar({
height: 450,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
disableDragging: true,
editable: false,
events: even,
eventClick: function (event) {
if (event.url) {
window.open(event.url);
return false;
}
}
});
callback(events);
},
error: function (xhr) {
debugger;
$('#calendar').fullCalendar({
height: 450,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
disableDragging: true,
editable: false,
events: []
});
return "";
}
});
}
</script>
您还可以使用Outlook Addins在sharepoint列表中添加outlook日历事件。 Visual Studio 2015支持创建支持Outlook Webapp和Outlook客户端的Webaddin。