设为首页 收藏本站
查看: 687|回复: 0

[经验分享] javascript调用Exchange webservice的例子

[复制链接]

尚未签到

发表于 2015-9-10 12:52:53 | 显示全部楼层 |阅读模式
发表时间:2008-2-28 10:24:00
  详见
user66/musictom/upload/228939146.rar


===============================================================
var _xmlHttp;
var _url = 'http://mail.pudong.sh/ews/exchange.asmx';
var _domain = 'pudong.sh';
function FindFolder() {
    var data = '<?xml version="1.0" encoding="utf-8"?>' +
                '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' +
                ' xmlns:t="http://www.blog.com.cn/http://schemas.microsoft.com/exchange/services/2006/types">' +
                '<soap:Body>' +
                    '<FindFolder Traversal="http://www.blog.com.cn/Shallow" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">' +
                        '<FolderShape>' +
                            '<t:BaseShape>Default</t:BaseShape>' +
                        '</FolderShape>' +
                        '<ParentFolderIds>' +
                            '<t:DistinguishedFolderId Id="http://www.blog.com.cn/inbox"/>' +
                        '</ParentFolderIds>' +
                    '</FindFolder>' +
                '</soap:Body>' +
                '</soap:Envelope>';
     data = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://www.blog.com.cn/http://schemas.microsoft.com/exchange/services/2006/types"><soap:Body><FindItem xmlns="http://www.blog.com.cn/http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://www.blog.com.cn/http://schemas.microsoft.com/exchange/services/2006/types" Traversal="http://www.blog.com.cn/Shallow"><ItemShape><t:BaseShape>IdOnly</t:BaseShape></ItemShape><ParentFolderIds><t:DistinguishedFolderId Id="inbox"/></ParentFolderIds></FindItem></soap:Body></soap:Envelope>';
    //GetItem
    data = '<?xml version="1.0" encoding="utf-8"?>' +
            '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' +
              ' xmlns:t="http://www.blog.com.cn/http://schemas.microsoft.com/exchange/services/2006/types">' +
              '<soap:Body>' +
                '<GetItem xmlns="http://www.blog.com.cn/http://schemas.microsoft.com/exchange/services/2006/messages">' +
                  '<ItemShape>' +
                       '<t:BaseShape>IdOnly</t:BaseShape>' +
                       '<t:BodyType>Text</t:BodyType>' +
  '<t:AdditionalProperties>' +
                      '<t:FieldURI FieldURI="item:Subject"/>' +
                      '<t:FieldURI FieldURI="item:ItemClass"/>' +
                      '<t:FieldURI FieldURI="item:Body"/>' +
                      '<t:FieldURI FieldURI="message:IsRead"/>' +
                      '<t:FieldURI FieldURI="message:From"/>' +
                      '<t:FieldURI FieldURI="message:Sender"/>' +
                      '<t:FieldURI FieldURI="message:ToRecipients"/>' +                     
                      '<t:FieldURI FieldURI="message:CcRecipients"/>' +  
                      '<t:FieldURI FieldURI="message:BccRecipients"/>' +  
                      '<t:FieldURI FieldURI="item:DisplayTo"/>' +  
                      '<t:FieldURI FieldURI="item:DisplayCc"/>' +
                      '<t:FieldURI FieldURI="item:Sensitivity"/>' +
                      '<t:FieldURI FieldURI="item:HasAttachments"/>' +
  '</t:AdditionalProperties>' +
                  '</ItemShape>' +
                  '<ItemIds>' +
                    '<t:ItemId Id="AAARAFRlc3RVc2VyMUBjcXl6LmNuAEYAAAAAAP02m1BjK+xJlfIqJWHBljYHAF5xhsS7E7tPveylhGgRgngAAACwR90AAF5xhsS7E7tPveylhGgRgngAAACwTjEAAA==" ChangeKey="CQAAABYAAABecYbEuxO7T73spYRoEYJ4AAAAsFR3"/>' +
                  '</ItemIds>' +
                '</GetItem>' +
              '</soap:Body>' +
            '</soap:Envelope>';
  _xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
     _xmlHttp.open("POST", _url, false, _domain + """testuser1", "App1234");
     _xmlHttp.onreadystatechange = fnCompleted;
     _xmlHttp.setRequestHeader("Content-Type","text/xml");
     _xmlHttp.setRequestHeader("SOAPAction","http://schemas.microsoft.com/exchange/services/2006/messages/GetItem");
     _xmlHttp.send(data);
}
  function fnCompleted() {
    if (_xmlHttp.readyState == "4") {
        if (_xmlHttp.status == "200") {
            var content = _xmlHttp.responseText;
            //alert(content);
            document.getElementById('txtx').innerText = content;
        } else {
         alert('status:' + _xmlHttp.status + ';responseText:' + _xmlHttp.responseText);
     }
    }
}
  function FindCalendar() {
    var data = '<?xml version="1.0" encoding="utf-8"?>' +
            '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' +
              ' xmlns:t="http://www.blog.com.cn/http://schemas.microsoft.com/exchange/services/2006/types">' +
              '<soap:Body>' +
                '<FindItem xmlns="http://www.blog.com.cn/http://schemas.microsoft.com/exchange/services/2006/messages">' +
                  '<ItemShape>' +
                       '<t:BaseShape>IdOnly</t:BaseShape>' +
                       '<t:BodyType>Text</t:BodyType>' +
  '<t:AdditionalProperties>' +
                      '<t:FieldURI FieldURI="item:Subject"/>' +
                      '<t:FieldURI FieldURI="item:ItemClass"/>' +
                      '<t:FieldURI FieldURI="item:Body"/>' +
                      '<t:FieldURI FieldURI="message:IsRead"/>' +
                      '<t:FieldURI FieldURI="message:From"/>' +
                      '<t:FieldURI FieldURI="message:Sender"/>' +
                      '<t:FieldURI FieldURI="message:ToRecipients"/>' +                     
                      '<t:FieldURI FieldURI="message:CcRecipients"/>' +  
                      '<t:FieldURI FieldURI="message:BccRecipients"/>' +  
                      '<t:FieldURI FieldURI="item:DisplayTo"/>' +  
                      '<t:FieldURI FieldURI="item:DisplayCc"/>' +
                      '<t:FieldURI FieldURI="item:Sensitivity"/>' +
                      '<t:FieldURI FieldURI="item:HasAttachments"/>' +
  
  
                    '</t:AdditionalProperties>' +
                  '</ItemShape>' +
                  '<ItemIds>' +
                    '<t:ItemId Id="AAARAFRlc3RVc2VyMUBjcXl6LmNuAEYAAAAAAP02m1BjK+xJlfIqJWHBljYHAF5xhsS7E7tPveylhGgRgngAAACwR90AAF5xhsS7E7tPveylhGgRgngAAACwTjEAAA==" ChangeKey="CQAAABYAAABecYbEuxO7T73spYRoEYJ4AAAAsFR3"/>' +
                  '</ItemIds>' +
                '</FindItem>' +
              '</soap:Body>' +
            '</soap:Envelope>';
            
            data = '<?xml version="1.0" encoding="utf-8"?>' +
            '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" ' +
                           'xmlns:t="http://www.blog.com.cn/http://schemas.microsoft.com/exchange/services/2006/types">' +
              '<soap:Body>' +
                '<FindItem xmlns="http://www.blog.com.cn/http://schemas.microsoft.com/exchange/services/2006/messages" ' +
                           'xmlns:t="http://www.blog.com.cn/http://schemas.microsoft.com/exchange/services/2006/types" ' +
                          'Traversal="http://www.blog.com.cn/Shallow">' +
                           
                  '<ItemShape>' +
                    '<t:BaseShape>IdOnly</t:BaseShape>' +
                    '<t:BodyType>Text</t:BodyType>' +
                    '<t:AdditionalProperties>' +
                        '<t:FieldURI FieldURI="item:ItemClass"/>' +
                        '<t:FieldURI FieldURI="item:Subject"/>' +
                        '<t:FieldURI FieldURI="item:Categories"/>' +                        
                        
                        
                        '<t:FieldURI FieldURI="calendar:Start"/>' +
                        '<t:FieldURI FieldURI="calendar:End"/>' +
                        //'<t:FieldURI FieldURI="calendar:Location"/>' +
                        //'<t:FieldURI FieldURI="calendar:NetShowUrl"/>' +
                        
                        //'<t:FieldURI FieldURI="calendar:OriginalStart"/>' +
                        '<t:FieldURI FieldURI="calendar:IsAllDayEvent"/>' +
                        '<t:FieldURI FieldURI="calendar:LegacyFreeBusyStatus"/>' +
                        '<t:FieldURI FieldURI="calendar:Location"/>' +
                        '<t:FieldURI FieldURI="calendar:When"/>' +
                        '<t:FieldURI FieldURI="calendar:IsMeeting"/>' +
                        //'<t:FieldURI FieldURI="calendar:IsCancelled"/>' +
                        '<t:FieldURI FieldURI="calendar:IsRecurring"/>' +
                        '<t:FieldURI FieldURI="calendar:MeetingRequestWasSent"/>' +
                        '<t:FieldURI FieldURI="calendar:IsResponseRequested"/>' +
                        '<t:FieldURI FieldURI="calendar:CalendarItemType"/>' +
                        '<t:FieldURI FieldURI="calendar:MyResponseType"/>' +
                        '<t:FieldURI FieldURI="calendar:Organizer"/>' +
                        //'<t:FieldURI FieldURI="calendar:RequiredAttendees"/>' +
                        //'<t:FieldURI FieldURI="calendar:OptionalAttendees"/>' +
                        //'<t:FieldURI FieldURI="calendar:Resources"/>' +
                        //'<t:FieldURI FieldURI="calendar:ConflictingMeetingCount"/>' +
                        //'<t:FieldURI FieldURI="calendar:AdjacentMeetingCount"/>' +
                        //'<t:FieldURI FieldURI="calendar:ConflictingMeetings"/>' +
                        //'<t:FieldURI FieldURI="calendar:AdjacentMeetings"/>' +
                        '<t:FieldURI FieldURI="calendar:Duration"/>' +
                        '<t:FieldURI FieldURI="calendar:TimeZone"/>' +
                        '<t:FieldURI FieldURI="calendar:AppointmentReplyTime"/>' +
                        '<t:FieldURI FieldURI="calendar:AppointmentSequenceNumber"/>' +
                        '<t:FieldURI FieldURI="calendar:AppointmentState"/>' +
                        //'<t:FieldURI FieldURI="calendar:Recurrence"/>' +
                        //'<t:FieldURI FieldURI="calendar:FirstOccurrence"/>' +
                        //'<t:FieldURI FieldURI="calendar:LastOccurrence"/>' +
                        //'<t:FieldURI FieldURI="calendar:ModifiedOccurrences"/>' +
                        //'<t:FieldURI FieldURI="calendar:DeletedOccurrences"/>' +
                        //'<t:FieldURI FieldURI="calendar:MeetingTimeZone"/>' +
                        '<t:FieldURI FieldURI="calendar:ConferenceType"/>' +
                        '<t:FieldURI FieldURI="calendar:AllowNewTimeProposal"/>' +
                        '<t:FieldURI FieldURI="calendar:IsOnlineMeeting"/>' +
                        '<t:FieldURI FieldURI="calendar:MeetingWorkspaceUrl"/>' +
                        '<t:FieldURI FieldURI="calendar:NetShowUrl"/>' +
  
                    '</t:AdditionalProperties>' +
                  '</ItemShape>' +
                  
                  //'<Restriction>' +
                      //'<Or xmlns="http://schemas.microsoft.com/exchange/services/2006/types"> ' +
                        /*'<IsEqualTo>' +
                          '<FieldURI FieldURI="http://www.blog.com.cn/item:DateTimeCreated"/>' +
                          '<FieldURIOrConstant>' +
                            '<FieldURI FieldURI="item:DateTimeReceived"/>' +
                          '</FieldURIOrConstant>' +
                        '</IsEqualTo>' +*/
                        /*'<IsEqualTo>' +
                          '<FieldURI FieldURI="item:Subject"/>' +
                          '<FieldURIOrConstant>' +
                            '<Constant Value="eee"/>' +
                          '</FieldURIOrConstant>' +
                        '</IsEqualTo>' +
                      '</Or>' +*/
                      /*'<SearchExpression>' +
                        '<IsEqualTo>' +
                          '<FieldURI FieldURI="item:Subject"/>' +
                          '<FieldURIOrConstant>' +
                            '<Constant Value="eee"/>' +
                          '</FieldURIOrConstant>' +
                        '</IsEqualTo>' +
                      '</SearchExpression>' +
                    '</Restriction>' +*/
                    
                    '<Restriction>' +
                    
                    //'    <ns5:Contains ContainmentComparison="IgnoreCase" ContainmentMode="FullString" ' +
                    //'                     xmlns:ns5="http://schemas.microsoft.com/exchange/services/2006/types">' +
                    //'          <ns5:FieldURI FieldURI="http://www.blog.com.cn/item:Subject"/>' +
                    //'          <ns5:Constant Value="eee" />' +
                    //'    </ns5:Contains>' +
                    
                    //'    <ns:IsEqualTo xmlns:ns="http://schemas.microsoft.com/exchange/services/2006/types">' +
                    //'          <ns:FieldURI FieldURI="http://www.blog.com.cn/calendar:Start"/>' +
                    //'          <ns:FieldURIOrConstant>' +
                    //'               <ns:Constant Value="2007-11-26T04:30:00Z" />' +
                    //'          </ns:FieldURIOrConstant>' +
                    //'    </ns:IsEqualTo>' +
                    
                    //'    <IsEqualTo xmlns="http://schemas.microsoft.com/exchange/services/2006/types">' +
                    //'          <FieldURI FieldURI="http://www.blog.com.cn/calendar:Start"/>' +
                    //'          <FieldURIOrConstant>' +
                    //'               <Constant Value="2007-11-26T04:30:00Z" />' +
                    //'          </FieldURIOrConstant>' +
                    //'    </IsEqualTo>' +
                    
                    //查询两个时间段的日程
                    '<And xmlns="http://schemas.microsoft.com/exchange/services/2006/types"> ' +
                    
                    //'    <ns1:IsGreaterThanOrEqualTo xmlns:ns1="http://www.blog.com.cn/http://schemas.microsoft.com/exchange/services/2006/types">' +
                    //'          <ns1:FieldURI FieldURI="http://www.blog.com.cn/calendar:Start"/>' +
                    //'          <ns1:FieldURIOrConstant>' +
                    //'               <ns1:Constant Value="2006-11-27T02:00:03Z" />' +
                    //'          </ns1:FieldURIOrConstant>' +
                    //'    </ns1:IsGreaterThanOrEqualTo>' +
  
                    '    <IsGreaterThanOrEqualTo>' +
                    '          <FieldURI FieldURI="calendar:Start"/>' +
                    '          <FieldURIOrConstant>' +
                    '               <Constant Value="2007-11-26T04:30:00Z" />' +
                    '          </FieldURIOrConstant>' +
                    '    </IsGreaterThanOrEqualTo>' +
                    
                    '    <IsLessThanOrEqualTo>' +
                    '          <FieldURI FieldURI="calendar:End"/>' +
                    '          <FieldURIOrConstant>' +
                    '               <Constant Value="2007-11-27T03:00:00Z" />' +
                    '          </FieldURIOrConstant>' +
                    '    </IsLessThanOrEqualTo>' +
  '</And>' +
                    '</Restriction>' +                    
                    
                  '<ParentFolderIds>' +
                    '<t:DistinguishedFolderId Id="calendar"/>' +
                  '</ParentFolderIds>' +
                '</FindItem>' +
              '</soap:Body>' +
            '</soap:Envelope>';
            
            //document.getElementById('txtx').innerText = data;
            //return;
  
     _xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
     _xmlHttp.open("POST", _url, false, _domain + """testuser1", "App1234");
     _xmlHttp.onreadystatechange = fnCalendarCompleted;
     _xmlHttp.setRequestHeader("Content-Type","text/xml");
     _xmlHttp.send(data);
}
  function fnCalendarCompleted() {
    if (_xmlHttp.readyState == "4") {
        if (_xmlHttp.status == "200") {
            var content = _xmlHttp.responseText;
            alert(content);
            document.getElementById('txtx').innerText = content;
        } else {
         alert('status:' + _xmlHttp.status + ';responseText:' + _xmlHttp.responseText);
     }
    }
}
//http://192.168.14.101/owa/?ae=PreFormAction&a=Open&t=IPM.Appointment
//&id=RgAAAAD9NptQYyvsSZXyKiVhwZY2BwBecYbEuxO7T73spYRoEYJ4AAAAsCdRAABecYbEuxO7T73spYRoEYJ4AAAAsEwvAAAP
  //<t:ItemId Id="AAARAFRlc3RVc2VyMUBjcXl6LmNuAEYAAAAAAP02m1BjK+xJlfIqJWHBljYHAF5xhsS7E7tPveylhGgRgngAAACwJ1EAAF5xhsS7E7tPveylhGgRgngAAACwTC8AAA=="
//ChangeKey="DwAAABYAAABecYbEuxO7T73spYRoEYJ4AAAAsFSm"
function GetUnReadMail() {
  data = '<?xml version="1.0" encoding="utf-8"?>' +
            '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" ' +
                           'xmlns:t="http://www.blog.com.cn/http://schemas.microsoft.com/exchange/services/2006/types">' +
              '<soap:Body>' +
                //'<FindItem xmlns="http://www.blog.com.cn/http://schemas.microsoft.com/exchange/services/2006/messages" ' +
                //           'xmlns:t="http://www.blog.com.cn/http://schemas.microsoft.com/exchange/services/2006/types" ' +
                //          'Traversal="http://www.blog.com.cn/Shallow">' +
               
                '<FindItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" ' +
                          'Traversal="http://www.blog.com.cn/Shallow">' +
                           
                  '<ItemShape>' +
                    '<t:BaseShape>IdOnly</t:BaseShape>' +
                    '<t:BodyType>Text</t:BodyType>' +
                    '<t:AdditionalProperties>' +
                        '<t:FieldURI FieldURI="item:ItemClass"/>' +
                        '<t:FieldURI FieldURI="item:Subject"/>' +
                        '<t:FieldURI FieldURI="item:Categories"/>' +
                        '<t:FieldURI FieldURI="message:IsRead"/>' +
                        '<t:FieldURI FieldURI="item:DateTimeReceived"/>' +
                    '</t:AdditionalProperties>' +
                  '</ItemShape>' +
                    
                    /*'<Restriction>' +
                    '    <IsEqualTo xmlns="http://schemas.microsoft.com/exchange/services/2006/types">' +
                    '          <FieldURI FieldURI="http://www.blog.com.cn/message:IsRead"/>' +
                    '          <FieldURIOrConstant>' +
                    '               <Constant Value="0" />' +
                    '          </FieldURIOrConstant>' +
                    '    </IsEqualTo>' +
                    '</Restriction>' +*/
                    
                    '<Restriction>' +
                    '    <t:IsEqualTo>' +
                    '

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-111966-1-1.html 上篇帖子: 90%使用WebDAV开发的Exchange邮件管理(三)——获取邮件 下篇帖子: 90%使用WebDAV开发的Exchange邮件管理(二)——Hello,获取未读邮件数!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表