在C#中通过webdav操作exchange

操作exchange类库代码

None.gif 为日历中的约会定义的实体
None.gif
using  System;
None.gif
using  System.Collections;
None.gif
None.gif
namespace  ISoftStone.AccessExchange.WebDav
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// CalendarItemInfo 的摘要说明。
ExpandedSubBlockEnd.gif    
/// </summary>

InBlock.gif    public class CalendarItemInfo
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
private string mName;
InBlock.gif        
public string Name
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return this.mName;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.mName = value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
private string mLocation;
InBlock.gif        
private DateTime mBeginTime ;
InBlock.gif        
private DateTime mEndTime;
InBlock.gif        
private int mInstanceType = 0;
InBlock.gif        
private string mBusyStatus = "BUSY";
InBlock.gif        
private string mMeetingStatus = "CONFIRMED";
InBlock.gif        
private bool mIsAllDayEvent = false;
InBlock.gif        
public bool IsAllDayEvent
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return this.mIsAllDayEvent;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.mIsAllDayEvent = value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
private bool mResponseRequested = true;
InBlock.gif        
public bool ResponseRequested
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return this.mResponseRequested;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.mResponseRequested = value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
private  int mReminderOffset = 900//seconds
InBlock.gif
        public int ReminderOffset
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return this.mReminderOffset;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.mReminderOffset = value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
private string  mMailToListMust;
InBlock.gif        
public string MailToListMust
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return this.mMailToListMust;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.mMailToListMust = value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
private string mMailToList;
InBlock.gif        
public string MailToList
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return this.mMailToList;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.mMailToList = value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private string mSubject;
InBlock.gif        
public string Subject
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return this.mSubject;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.mSubject = value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
private string mHtmlDescription;
InBlock.gif        
public string HtmlDescription
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return this.mHtmlDescription;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.mHtmlDescription = value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
private bool mIsFinvited = true;
InBlock.gif        
public bool IsFinvited
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return this.mIsFinvited;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.mIsFinvited = value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 所在位置
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public string Location
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return this.mLocation;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.mLocation = value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 约会开始时间
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public DateTime BeginTime
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return mBeginTime;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                mBeginTime 
= value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 约会结束时间
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public DateTime EndTime
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return this.mEndTime;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.mEndTime = value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
public int InstanceType
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return this.mInstanceType;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.mInstanceType = value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
public string BusyStatus
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return this.mBusyStatus;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.mBusyStatus = value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
public string MeetingStatus
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return this.mMeetingStatus;
InBlock.gif
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.mMeetingStatus = value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
public int GetBoolInt(bool any)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if (any)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return 1;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
return 0;
ExpandedSubBlockEnd.gif        }

InBlock.gif        
InBlock.gif
InBlock.gif        
public CalendarItemInfo()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//
InBlock.gif            
// TODO: 在此处添加构造函数逻辑
InBlock.gif            
//
ExpandedSubBlockEnd.gif
        }

ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif


User

None.gif using  System;
None.gif
None.gif
namespace  ISoftStone.AccessExchange.WebDav
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// User 的摘要说明。
ExpandedSubBlockEnd.gif    
/// </summary>

InBlock.gif    public class User
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
private string m_Name;
InBlock.gif        
private string m_Password;
InBlock.gif        
private string m_Domain;
InBlock.gif
InBlock.gif        
public string Name
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return m_Name;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                m_Name 
= value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
public string Password
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return m_Password;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                m_Password 
= value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
public string Domain
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return m_Domain;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                m_Domain 
= value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
private User(string name,string password,string domain)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            m_Name 
= name;
InBlock.gif            m_Password 
= password;
InBlock.gif            m_Domain 
= domain;
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public static User GetUser(string name,string password,string domain)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
return  new User(name,password,domain);
InBlock.gif            
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public static User GetUser(string name,string password)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
return new User(name,password,String.Empty);
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif

session
None.gif using  System;
None.gif
using  System.Net;
None.gif
None.gif
namespace  ISoftStone.AccessExchange.WebDav
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
///This class is for the session management of WebExchange class. 
ExpandedSubBlockEnd.gif    
/// </summary>

InBlock.gif    public class WebDavSession
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif        
Fields#region Fields 
InBlock.gif
InBlock.gif        
private string m_UserMailUrl;
InBlock.gif        
private ICredentials m_Credentials;
InBlock.gif        
private WebProxy m_Proxy;
InBlock.gif
ExpandedSubBlockEnd.gif        
#endregion

ExpandedSubBlockStart.gifContractedSubBlock.gif        
Property#region Property
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// user's mailbox url
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public string UserMailUrl
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return m_UserMailUrl;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                m_UserMailUrl 
= value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// web proxy 
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public WebProxy Proxy
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return m_Proxy;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                m_Proxy 
= value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
public ICredentials Credentials 
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return m_Credentials;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                m_Credentials 
= value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif        
#endregion

InBlock.gif
InBlock.gif        
public static WebDavSession GetSession(ICredentials obj)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            WebDavSession session 
=  new WebDavSession();
InBlock.gif            session.Credentials 
= obj;
InBlock.gif            
return session;
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public static WebDavSession GetSession(User user)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
return GetSession(user,String.Empty);
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public static WebDavSession GetSession(User user,WebProxy proxy)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
return GetSession(user,String.Empty,proxy);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
public static WebDavSession GetSession(User user,string userMailUrl)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
return GetSession(user,userMailUrl,null);
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public static WebDavSession GetSession(User user,string userMailUrl,WebProxy proxy)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            WebDavSession session 
= new WebDavSession();
InBlock.gif            session.UserMailUrl 
= userMailUrl;
InBlock.gif            session.Proxy 
= proxy;
InBlock.gif            
if(user.Domain.Equals(String.Empty))
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                CredentialCache myCredentialCache 
= new CredentialCache();
InBlock.gif                myCredentialCache.Add( 
new System.Uri(userMailUrl),"NTLM",
InBlock.gif                    
new NetworkCredential(user.Name,user.Password));
InBlock.gif                session.Credentials 
= myCredentialCache;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                CredentialCache myCredentialCache 
= new CredentialCache();
InBlock.gif                myCredentialCache.Add( 
new System.Uri(userMailUrl),"NTLM",
InBlock.gif                    
new NetworkCredential(user.Name,user.Password,user.Domain));
InBlock.gif                session.Credentials 
= myCredentialCache;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
return session;
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public WebDavSession()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//
InBlock.gif            
// TODO: 在此处添加构造函数逻辑
InBlock.gif            
//
ExpandedSubBlockEnd.gif
        }

ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif


None.gif using  System;
None.gif
using  System.Net;
None.gif
using  System.Text;
None.gif
using  System.Xml;
None.gif
using  System.IO;
None.gif
using  System.Data;
None.gif
None.gif
namespace  ISoftStone.AccessExchange.WebDav
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// WebExchange 的摘要说明。
ExpandedSubBlockEnd.gif    
/// </summary>

InBlock.gif    public class WebExchange
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
private WebDavSession m_Session;
InBlock.gif        
private string m_Url;
InBlock.gif        
private Encoding m_Encode;
InBlock.gif
InBlock.gif        
private HttpWebRequest objRequest;
InBlock.gif        
private WebResponse objResponse;
InBlock.gif
InBlock.gif        
InBlock.gif        
InBlock.gif
InBlock.gif        
public WebDavSession Session
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if(m_Session == null)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    m_Session 
= new WebDavSession();
ExpandedSubBlockEnd.gif                }

InBlock.gif                
return m_Session;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                m_Session 
= value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
public string Url
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if(m_Url != null)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
if(m_Url.LastIndexOf("/"== m_Url.Length -1)
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        
return m_Url.Substring(0,m_Url.Length-1);
ExpandedSubBlockEnd.gif                    }

ExpandedSubBlockEnd.gif                }

InBlock.gif                
return m_Url;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                m_Url 
= value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
public Encoding Encode
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if (m_Encode == null)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    m_Encode 
= new UTF8Encoding();
ExpandedSubBlockEnd.gif                }

InBlock.gif                
return m_Encode;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                m_Encode 
= value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
InBlock.gif        
public WebExchange(WebDavSession webDavSession)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            m_Session 
= webDavSession;
InBlock.gif            m_Url 
= webDavSession.UserMailUrl;
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public WebExchange(WebDavSession webDavSession,string url)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            m_Session 
= webDavSession;
InBlock.gif            m_Url 
= url;
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public WebExchange(string url)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            m_Url 
= url;
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public void CreateCalendarItem(CalendarItemInfo itemInfo)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
InBlock.gif
InBlock.gif            
byte[] bytes = null;
InBlock.gif            Stream requestStream 
= null;
InBlock.gif            Stream responseStream 
= null;
InBlock.gif            
string strMailbox = "jianli";
InBlock.gif            
string strXMLNSInfo =null;
InBlock.gif            
try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                objRequest 
= (System.Net.HttpWebRequest)HttpWebRequest.Create(this.Url + "/" + itemInfo.Name);
InBlock.gif                
//objRequest = (HttpWebRequest)HttpWebRequest.Create(this.Url + "/" + "testdee");
InBlock.gif                
// Add the network credentials to the request.
InBlock.gif
                objRequest.Credentials = Session.Credentials;
InBlock.gif                
// Specify the DELETE method.
InBlock.gif
                objRequest.Method = "PROPPATCH";
InBlock.gif                
// XML namespace info for the WebDAV request.
InBlock.gif
                strXMLNSInfo = "xmlns:g=\"DAV:\" "
InBlock.gif                    
+ "xmlns:e=\"http://schemas.microsoft.com/exchange/\" "
InBlock.gif
                    + "xmlns:mapi=\"http://schemas.microsoft.com/mapi/\" "
InBlock.gif
                    + "xmlns:mapit=\"http://schemas.microsoft.com/mapi/proptag/\" "
InBlock.gif
                    + "xmlns:x=\"xml:\" xmlns:cal=\"urn:schemas:calendar:\" "
InBlock.gif                    
+ "xmlns:dt=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\" "
InBlock.gif                    
+ "xmlns:header=\"urn:schemas:mailheader:\" "
InBlock.gif                    
+ "xmlns:mail=\"urn:schemas:httpmail:\"";
InBlock.gif
InBlock.gif                
// Set the appointment item properties.  To create an all-day meeting,
InBlock.gif                
// set the dtstart/dtend range for 24 hours or more and set the alldayevent property
InBlock.gif                
// to 1.  See the documentation on the properties
InBlock.gif                
// in the urn:schemas:calendar: namespace for more information.
InBlock.gif
                string strCalInfo = "<cal:location>" + itemInfo.Location + "</cal:location>"
InBlock.gif                    
+ "<cal:dtstart dt:dt=\"dateTime.tz\">2005-04-24T08:00:00.000Z</cal:dtstart>"
InBlock.gif                
InBlock.gif                    
+ "<cal:dtend dt:dt=\"dateTime.tz\">2005-04-24T08:40:00.000Z</cal:dtend>"
InBlock.gif
//                    + "<cal:dtstart dt:dt=\"dateTime.tz\">" + itemInfo.BeginTime.ToShortDateString() + "T" + itemInfo.BeginTime.ToLongTimeString() + ".000Z" + "</cal:dtstart>"
InBlock.gif
//                    + "<cal:dtend dt:dt=\"dateTime.tz\">"  + itemInfo.EndTime.ToShortDateString() + "T" + itemInfo.EndTime.ToLongTimeString() + ".000Z" +  "</cal:dtend>"
InBlock.gif
                    + "<cal:instancetype dt:dt=\"int\">" + itemInfo.InstanceType.ToString() + "</cal:instancetype>"
InBlock.gif                    
InBlock.gif
InBlock.gif                    
InBlock.gif
InBlock.gif                    
+ "<cal:busystatus>" + itemInfo.BusyStatus + "</cal:busystatus>"
InBlock.gif                    
+ "<cal:meetingstatus> " + itemInfo.MeetingStatus.ToString() + "</cal:meetingstatus>"
InBlock.gif                    
+ "<cal:alldayevent dt:dt=\"boolean\">" + itemInfo.GetBoolInt(itemInfo.IsAllDayEvent).ToString() + "</cal:alldayevent>"
InBlock.gif                    
+ "<cal:responserequested dt:dt=\"boolean\">" + itemInfo.GetBoolInt(itemInfo.IsAllDayEvent).ToString() + "</cal:responserequested>"
InBlock.gif                    
// Set the reminder time (in seconds).
InBlock.gif
                    + "<cal:reminderoffset dt:dt=\"int\">" + itemInfo.ReminderOffset.ToString() +"</cal:reminderoffset>";
InBlock.gif
InBlock.gif
//                string strCalInfo = "<cal:location>meetappt Location</cal:location>"
InBlock.gif
//                    + "<cal:dtstart dt:dt=\"dateTime.tz\">2004-05-18T23:00:00.000Z</cal:dtstart>"
InBlock.gif
//                    + "<cal:dtend dt:dt=\"dateTime.tz\">2004-05-18T23:30:00.000Z</cal:dtend>"
InBlock.gif
//                    + "<cal:instancetype dt:dt=\"int\">0</cal:instancetype>"
InBlock.gif
//                    + "<cal:busystatus>BUSY</cal:busystatus>"
InBlock.gif
//                    + "<cal:meetingstatus>CONFIRMED</cal:meetingstatus>"
InBlock.gif
//                    + "<cal:alldayevent dt:dt=\"boolean\">0</cal:alldayevent>"
InBlock.gif
//                    + "<cal:responserequested dt:dt=\"boolean\">1</cal:responserequested>"
InBlock.gif
//
InBlock.gif
//                    // Set the reminder time (in seconds).
InBlock.gif
//                    + "<cal:reminderoffset dt:dt=\"int\">900</cal:reminderoffset>";
InBlock.gif
//
InBlock.gif
//
InBlock.gif
InBlock.gif
InBlock.gif                
// Set the required attendee of the appointment.
InBlock.gif
                string strHeaderInfo = "<header:to>" + itemInfo.MailToListMust + "</header:to>";
InBlock.gif
InBlock.gif                
// Set the subject of the appointment.
InBlock.gif
                string strMailInfo = "<mail:subject>" + itemInfo.Subject + "</mail:subject>"
InBlock.gif                    
+ "<mail:htmldescription>" + itemInfo.HtmlDescription + "</mail:htmldescription>";
InBlock.gif
InBlock.gif                
// Build the XML body of the PROPPATCH request.
InBlock.gif
                string strApptRequest = "<?xml version=\"1.0\"?>"
InBlock.gif                    
+ "<g:propertyupdate " + strXMLNSInfo + ">"
InBlock.gif                    
+ "<g:set><g:prop>"
InBlock.gif                    
+ "<g:contentclass>urn:content-classes:appointment</g:contentclass>"
InBlock.gif                    
+ "<e:outlookmessageclass>IPM.Appointment</e:outlookmessageclass>"
InBlock.gif                    
+ strMailInfo
InBlock.gif                    
+ strCalInfo
InBlock.gif                    
+ strHeaderInfo
InBlock.gif                    
+ "<mapi:finvited dt:dt=\"boolean\">1</mapi:finvited>"
InBlock.gif                    
+ "</g:prop></g:set>"
InBlock.gif                    
+ "</g:propertyupdate>";
InBlock.gif
InBlock.gif
InBlock.gif                bytes 
= this.Encode.GetBytes((string)strApptRequest);
InBlock.gif                
InBlock.gif                
// Set the content header length.  This must be
InBlock.gif                
// done before writing data to the request stream.
InBlock.gif
                objRequest.ContentLength = bytes.Length;
InBlock.gif
InBlock.gif                
// Get a reference to the request stream.
InBlock.gif
                requestStream = objRequest.GetRequestStream();
InBlock.gif
InBlock.gif                
InBlock.gif                
// Write the request body to the request stream.
InBlock.gif
                requestStream.Write(bytes, 0, bytes.Length);
InBlock.gif
InBlock.gif                
// Close the Stream object to release the connection
InBlock.gif                
// for further use.
InBlock.gif
                requestStream.Close();
InBlock.gif
InBlock.gif                
// Set the content type header.
InBlock.gif
                objRequest.ContentType = "text/xml";
InBlock.gif
InBlock.gif                
// Send the PROPFIND method request and get the
InBlock.gif                
// response from the server.
InBlock.gif
                objResponse = (HttpWebResponse)objRequest.GetResponse();
InBlock.gif                
//return null;
InBlock.gif
InBlock.gif                
// Get the XML response stream.
InBlock.gif
                responseStream = objResponse.GetResponseStream();
InBlock.gif                
// Close the HttpWebResponse object.
InBlock.gif
                objResponse.Close();
InBlock.gif                responseStream.Close();
InBlock.gif                
//Console.WriteLine("Item successfully deleted.")
ExpandedSubBlockEnd.gif
            }

InBlock.gif            
catch(Exception ex)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
// Catch any exceptions. Any error codes from the PROPPATCH
InBlock.gif                
// method request on the server will be caught
InBlock.gif                
// here, also.
InBlock.gif
                throw new Exception("can't create item " + ex.ToString());
ExpandedSubBlockEnd.gif            }

InBlock.gif
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public void CreateCalendarItem(string itemName)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
byte[] bytes = null;
InBlock.gif            Stream requestStream 
= null;
InBlock.gif            Stream responseStream 
= null;
InBlock.gif            
string strMailbox = "jianli";
InBlock.gif            
try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                objRequest 
= (System.Net.HttpWebRequest)HttpWebRequest.Create(this.Url + "/" + itemName);
InBlock.gif
InBlock.gif                
// Add the network credentials to the request.
InBlock.gif
                objRequest.Credentials = this.Session.Credentials;
InBlock.gif
InBlock.gif                
// Specify the DELETE method.
InBlock.gif
                objRequest.Method = "PROPPATCH";
InBlock.gif
InBlock.gif                
// XML namespace info for the WebDAV request.
InBlock.gif
                string strXMLNSInfo = "xmlns:g=\"DAV:\" "
InBlock.gif                    
+ "xmlns:e=\"http://schemas.microsoft.com/exchange/\" "
InBlock.gif
                    + "xmlns:mapi=\"http://schemas.microsoft.com/mapi/\" "
InBlock.gif
                    + "xmlns:mapit=\"http://schemas.microsoft.com/mapi/proptag/\" "
InBlock.gif
                    + "xmlns:x=\"xml:\" xmlns:cal=\"urn:schemas:calendar:\" "
InBlock.gif                    
+ "xmlns:dt=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\" "
InBlock.gif                    
+ "xmlns:header=\"urn:schemas:mailheader:\" "
InBlock.gif                    
+ "xmlns:mail=\"urn:schemas:httpmail:\"";
InBlock.gif
InBlock.gif                
// Set the appointment item properties.  To create an all-day meeting,
InBlock.gif                
// set the dtstart/dtend range for 24 hours or more and set the alldayevent property
InBlock.gif                
// to 1.  See the documentation on the properties
InBlock.gif                
// in the urn:schemas:calendar: namespace for more information.
InBlock.gif
                string strCalInfo = "<cal:location>meetappt Location</cal:location>"
InBlock.gif                    
+ "<cal:dtstart dt:dt=\"dateTime.tz\">2004-05-18T23:00:00.000Z</cal:dtstart>"
InBlock.gif                    
+ "<cal:dtend dt:dt=\"dateTime.tz\">2004-05-18T23:30:00.000Z</cal:dtend>"
InBlock.gif                    
+ "<cal:instancetype dt:dt=\"int\">0</cal:instancetype>"
InBlock.gif                    
+ "<cal:busystatus>BUSY</cal:busystatus>"
InBlock.gif                    
+ "<cal:meetingstatus>CONFIRMED</cal:meetingstatus>"
InBlock.gif                    
+ "<cal:alldayevent dt:dt=\"boolean\">0</cal:alldayevent>"
InBlock.gif                    
+ "<cal:responserequested dt:dt=\"boolean\">1</cal:responserequested>"
InBlock.gif
InBlock.gif                    
// Set the reminder time (in seconds).
InBlock.gif
                    + "<cal:reminderoffset dt:dt=\"int\">900</cal:reminderoffset>";
InBlock.gif
InBlock.gif                
// Set the required attendee of the appointment.
InBlock.gif
                string strHeaderInfo = "<header:to>" + strMailbox + ";章清平 &lt;qpzhang@iisdnet.com &gt;></header:to>";
InBlock.gif
InBlock.gif                
// Set the subject of the appointment.
InBlock.gif
                string strMailInfo = "<mail:subject>Test Appointment Subject</mail:subject>"
InBlock.gif                    
+ "<mail:htmldescription>Let's meet here</mail:htmldescription>";
InBlock.gif
InBlock.gif                
// Build the XML body of the PROPPATCH request.
InBlock.gif
                string strApptRequest = "<?xml version=\"1.0\"?>"
InBlock.gif                    
+ "<g:propertyupdate " + strXMLNSInfo + ">"
InBlock.gif                    
+ "<g:set><g:prop>"
InBlock.gif                    
+ "<g:contentclass>urn:content-classes:appointment</g:contentclass>"
InBlock.gif                    
+ "<e:outlookmessageclass>IPM.Appointment</e:outlookmessageclass>"
InBlock.gif                    
+ strMailInfo
InBlock.gif                    
+ strCalInfo
InBlock.gif                    
+ strHeaderInfo
InBlock.gif                    
+ "<mapi:finvited dt:dt=\"boolean\">1</mapi:finvited>"
InBlock.gif                    
+ "</g:prop></g:set>"
InBlock.gif                    
+ "</g:propertyupdate>";
InBlock.gif
InBlock.gif
InBlock.gif                bytes 
= this.Encode.GetBytes((string)strApptRequest);
InBlock.gif                
InBlock.gif                
// Set the content header length.  This must be
InBlock.gif                
// done before writing data to the request stream.
InBlock.gif
                objRequest.ContentLength = bytes.Length;
InBlock.gif
InBlock.gif                
// Get a reference to the request stream.
InBlock.gif
                requestStream = objRequest.GetRequestStream();
InBlock.gif
InBlock.gif                
InBlock.gif                
// Write the request body to the request stream.
InBlock.gif
                requestStream.Write(bytes, 0, bytes.Length);
InBlock.gif
InBlock.gif                
// Close the Stream object to release the connection
InBlock.gif                
// for further use.
InBlock.gif
                requestStream.Close();
InBlock.gif
InBlock.gif                
// Set the content type header.
InBlock.gif
                objRequest.ContentType = "text/xml";
InBlock.gif
InBlock.gif                
InBlock.gif                
// Send the PROPFIND method request and get the
InBlock.gif                
// response from the server.
InBlock.gif
                objResponse = (HttpWebResponse)objRequest.GetResponse();
InBlock.gif                
//return null;
InBlock.gif
InBlock.gif                
// Get the XML response stream.
InBlock.gif
                responseStream = objResponse.GetResponseStream();
InBlock.gif
InBlock.gif                
// Close the HttpWebResponse object.
InBlock.gif
                objResponse.Close();
InBlock.gif                responseStream.Close();
InBlock.gif                
InBlock.gif
InBlock.gif                
//Console.WriteLine("Item successfully deleted.")
InBlock.gif

ExpandedSubBlockEnd.gif            }

InBlock.gif            
catch(Exception ex)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
// Catch any exceptions. Any error codes from the PROPPATCH
InBlock.gif                
// method request on the server will be caught
InBlock.gif                
// here, also.
InBlock.gif
                throw new Exception("can't create item " + ex.ToString());
ExpandedSubBlockEnd.gif            }

InBlock.gif
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public void GetInfo()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif
//            string strXml;
InBlock.gif
//            strXml = "<?xml version='"+"1.0"+"'?>";
InBlock.gif
//            strXml = strXml + "<a:propfind xmlns:a='"+"DAV:"+"'  xmlns:e='"+"urn:schemas:httpmail:'"+">";
InBlock.gif
//            strXml = strXml + "<a:prop>";
InBlock.gif
//            //日历
InBlock.gif
//            strXml = strXml + "<e:calendar/>";
InBlock.gif
//            
InBlock.gif
//            //联系人
InBlock.gif
//            strXml = strXml + "<e:contacts/>";
InBlock.gif
//            
InBlock.gif
//            //回收站
InBlock.gif
//            strXml = strXml + "<e:deleteditems/>";
InBlock.gif
//            
InBlock.gif
//            //草稿
InBlock.gif
//            strXml = strXml + "<e:drafts/>";
InBlock.gif
//            
InBlock.gif
//            //收件箱
InBlock.gif
//            strXml = strXml + "<e:inbox/>";
InBlock.gif
//            
InBlock.gif
//            //日记
InBlock.gif
//            strXml = strXml + "<e:journal/>";
InBlock.gif
//            
InBlock.gif
//            //便笺
InBlock.gif
//            strXml = strXml + "<e:notes/>";
InBlock.gif
//            
InBlock.gif
//            //发件箱
InBlock.gif
//            strXml = strXml + "<e:outbox/>";
InBlock.gif
//            
InBlock.gif
//            //已发邮件
InBlock.gif
//            strXml = strXml + "<e:sentitems/>";
InBlock.gif
//            
InBlock.gif
//            //任务
InBlock.gif
//            strXml = strXml + "<e:tasks/>";
InBlock.gif
//            
InBlock.gif
//            //短信
InBlock.gif
//            strXml = strXml + "<e:sendmsg/>";
InBlock.gif
//            strXml = strXml + "<e:msgfolderroot/>";
InBlock.gif
//            strXml = strXml + "</a:prop>";
InBlock.gif
//            strXml = strXml + "</a:propfind>";
InBlock.gif
//
InBlock.gif
//            //声明XMLHTTP对象
InBlock.gif
//            MSXML2.XMLHTTP30Class objXmlHttp=new MSXML2.XMLHTTP30Class();
InBlock.gif
//            //声明DOMDocument对象
InBlock.gif
//            MSXML2.DOMDocument30Class  objXmlDOMDocument=new MSXML2.DOMDocument30Class();
InBlock.gif
//            objXmlHttp.open("PROPFIND",strUserFolder,false,strDomainName+"\\"+strUserName,strUserPwd);
InBlock.gif
//            objXmlHttp.setRequestHeader("content-type","text/xml");
InBlock.gif
//            objXmlHttp.setRequestHeader("depth","0");
InBlock.gif
//            objXmlHttp.send(strXml);
InBlock.gif
//    
InBlock.gif
//            if (objXmlHttp.status.ToString()=="207") //DAV读取正确
InBlock.gif
//            {
InBlock.gif
//                objXmlDOMDocument.load(objXmlHttp.responseXML);
InBlock.gif
//                
InBlock.gif
//                //日历
InBlock.gif
//                strCalendar=objXmlDOMDocument.selectSingleNode("//a:multistatus/a:response/a:propstat/a:prop/d:calendar").text;
InBlock.gif
//                
InBlock.gif
//                //联系人
InBlock.gif
//                strContacts=objXmlDOMDocument.selectSingleNode("//a:multistatus/a:response/a:propstat/a:prop/d:contacts").text;
InBlock.gif
//                
InBlock.gif
//                //垃圾箱
InBlock.gif
//                strDeleteditems=objXmlDOMDocument.selectSingleNode("//a:multistatus/a:response/a:propstat/a:prop/d:deleteditems").text;
InBlock.gif
//                
InBlock.gif
//                //草稿
InBlock.gif
//                strDrafts=objXmlDOMDocument.selectSingleNode("//a:multistatus/a:response/a:propstat/a:prop/d:drafts").text;
InBlock.gif
//                
InBlock.gif
//                //收件箱
InBlock.gif
//                strInbox=objXmlDOMDocument.selectSingleNode("//a:multistatus/a:response/a:propstat/a:prop/d:inbox").text;
InBlock.gif
//                
InBlock.gif
//                //日记
InBlock.gif
//                strJournal=objXmlDOMDocument.selectSingleNode("//a:multistatus/a:response/a:propstat/a:prop/d:journal").text;
InBlock.gif
//                
InBlock.gif
//                //便笺
InBlock.gif
//                strNotes=objXmlDOMDocument.selectSingleNode("//a:multistatus/a:response/a:propstat/a:prop/d:notes").text;
InBlock.gif
//                
InBlock.gif
//                //发件箱
InBlock.gif
//                strOutbox=objXmlDOMDocument.selectSingleNode("//a:multistatus/a:response/a:propstat/a:prop/d:outbox").text;
InBlock.gif
//                
InBlock.gif
//                //已发邮件
InBlock.gif
//                strSentitems=objXmlDOMDocument.selectSingleNode("//a:multistatus/a:response/a:propstat/a:prop/d:sentitems").text;
InBlock.gif
//                
InBlock.gif
//                //任务
InBlock.gif
//                strTasks=objXmlDOMDocument.selectSingleNode("//a:multistatus/a:response/a:propstat/a:prop/d:tasks").text;
InBlock.gif
//                        
InBlock.gif
//                //短信
InBlock.gif
//                strSendmsg=objXmlDOMDocument.selectSingleNode("//a:multistatus/a:response/a:propstat/a:prop/d:sendmsg").text;
InBlock.gif
//                
InBlock.gif
//                strMsgfolderroot=objXmlDOMDocument.selectSingleNode("//a:multistatus/a:response/a:propstat/a:prop/d:msgfolderroot").text;
InBlock.gif
//                
InBlock.gif
//                //Label1.Text=strCalendar+strDeleteditems;//debug
InBlock.gif
//            }
InBlock.gif
//            else //DAV读取错误
InBlock.gif
//            {
InBlock.gif
//                Response.Write("<?xml version='1.0' encoding='GB2312'?>");
InBlock.gif
//                Response.Write("<Error>");
InBlock.gif
//                Response.Write("<Status>" + objXmlHttp.status + "</Status>");
InBlock.gif
//                Response.Write("<Statustext>" + objXmlHttp.statusText.ToString() + "</Statustext>");
InBlock.gif
//                Response.Write("</Error>");
InBlock.gif
//            }
InBlock.gif
//        
InBlock.gif

InBlock.gif
InBlock.gif
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public XmlDocument SearchItems(string xmlSearchBody)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//string strSrcURI = ItemURL;
InBlock.gif

InBlock.gif            
byte[] bytes = null;
InBlock.gif            Stream requestStream 
= null;
InBlock.gif            Stream responseStream 
= null;
InBlock.gif            XmlDocument responseXmlDoc 
= null;
InBlock.gif
InBlock.gif            
try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
InBlock.gif                
// Create the HttpWebRequest object.
InBlock.gif
                objRequest = (HttpWebRequest)HttpWebRequest.Create(Url);
InBlock.gif                
// Add the network credentials to the request.
InBlock.gif
                objRequest.Credentials = m_Session.Credentials;
InBlock.gif                
// Specify the method.
InBlock.gif                
//objRequest.Method = "PROPFIND";
InBlock.gif
                objRequest.Method = "SEARCH";
InBlock.gif                
// Encode the body 
InBlock.gif
                bytes = this.Encode.GetBytes((string)xmlSearchBody);
InBlock.gif                
InBlock.gif                
// Set the content header length.  This must be
InBlock.gif                
// done before writing data to the request stream.
InBlock.gif
                objRequest.ContentLength = bytes.Length;
InBlock.gif
InBlock.gif                
// Get a reference to the request stream.
InBlock.gif
                requestStream = objRequest.GetRequestStream();
InBlock.gif                
InBlock.gif
InBlock.gif                
// Write the request body to the request stream.
InBlock.gif
                requestStream.Write(bytes, 0, bytes.Length);
InBlock.gif
InBlock.gif                
// Close the Stream object to release the connection
InBlock.gif                
// for further use.
InBlock.gif
                requestStream.Close();
InBlock.gif
InBlock.gif                
// Set the content type header.
InBlock.gif
                objRequest.ContentType = "text/xml";
InBlock.gif
InBlock.gif                
// Send the PROPFIND method request and get the
InBlock.gif                
// response from the server.
InBlock.gif
                objResponse = (HttpWebResponse)objRequest.GetResponse();
InBlock.gif                
//return null;
InBlock.gif
InBlock.gif                
// Get the XML response stream.
InBlock.gif
                responseStream = objResponse.GetResponseStream();
InBlock.gif
InBlock.gif                
// Create the XmlDocument object from the XML response stream.
InBlock.gif
                responseXmlDoc = new XmlDocument();
InBlock.gif                responseXmlDoc.Load(responseStream);
InBlock.gif                
InBlock.gif                
// Clean up.
InBlock.gif
                responseStream.Close();
InBlock.gif                objResponse.Close();
InBlock.gif                
InBlock.gif                
//responseXmlDoc.Save(@"C:\jjj.xml");
InBlock.gif
                return responseXmlDoc;
InBlock.gif
ExpandedSubBlockEnd.gif            }

InBlock.gif            
catch(Exception e)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
throw new Exception("Can't get the data" + e.ToString());
ExpandedSubBlockEnd.gif            }
    
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public XmlDocument GetItemFieldValue(string strBody)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//string strSrcURI = ItemURL;
InBlock.gif

InBlock.gif            
byte[] bytes = null;
InBlock.gif            Stream requestStream 
= null;
InBlock.gif            Stream responseStream 
= null;
InBlock.gif            XmlDocument responseXmlDoc 
= null;
InBlock.gif            
InBlock.gif
InBlock.gif            
try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
InBlock.gif                
// Create the HttpWebRequest object.
InBlock.gif
                objRequest = (HttpWebRequest)HttpWebRequest.Create(Url);
InBlock.gif                
// Add the network credentials to the request.
InBlock.gif
                objRequest.Credentials = m_Session.Credentials;
InBlock.gif                
// Specify the method.
InBlock.gif
                objRequest.Method = "PROPFIND";
InBlock.gif                
//objRequest.Method = "SEARCH";
InBlock.gif                
// Encode the body 
InBlock.gif
                bytes = this.Encode.GetBytes((string)strBody);
InBlock.gif                
InBlock.gif                
// Set the content header length.  This must be
InBlock.gif                
// done before writing data to the request stream.
InBlock.gif
                objRequest.ContentLength = bytes.Length;
InBlock.gif
InBlock.gif                
// Get a reference to the request stream.
InBlock.gif
                requestStream = objRequest.GetRequestStream();
InBlock.gif                
InBlock.gif
InBlock.gif                
// Write the request body to the request stream.
InBlock.gif
                requestStream.Write(bytes, 0, bytes.Length);
InBlock.gif
InBlock.gif                
// Close the Stream object to release the connection
InBlock.gif                
// for further use.
InBlock.gif
                requestStream.Close();
InBlock.gif
InBlock.gif                
// Set the content type header.
InBlock.gif
                objRequest.ContentType = "text/xml";
InBlock.gif
InBlock.gif                
// Send the PROPFIND method request and get the
InBlock.gif                
// response from the server.
InBlock.gif
                objResponse = (HttpWebResponse)objRequest.GetResponse();
InBlock.gif                
//return null;
InBlock.gif
InBlock.gif                
// Get the XML response stream.
InBlock.gif
                responseStream = objResponse.GetResponseStream();
InBlock.gif
InBlock.gif                
// Create the XmlDocument object from the XML response stream.
InBlock.gif
                responseXmlDoc = new XmlDocument();
InBlock.gif                responseXmlDoc.Load(responseStream);
InBlock.gif                
InBlock.gif                
// Clean up.
InBlock.gif
                responseStream.Close();
InBlock.gif                objResponse.Close();
InBlock.gif                responseXmlDoc.Save(
@"C:\jjj.xml");
InBlock.gif                
return responseXmlDoc;
InBlock.gif
ExpandedSubBlockEnd.gif            }

InBlock.gif            
catch(Exception e)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
throw new Exception("Can't get the data" + e.ToString());
ExpandedSubBlockEnd.gif            }
            
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 删除一个item
InBlock.gif        
/// </summary>
ExpandedSubBlockEnd.gif        
/// <param name="itemUrl"></param>

InBlock.gif        public void DeleteItem(string itemUrl)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                objRequest 
= (System.Net.HttpWebRequest)HttpWebRequest.Create(itemUrl);
InBlock.gif
InBlock.gif                
// Add the network credentials to the request.
InBlock.gif
                objRequest.Credentials = this.Session.Credentials;
InBlock.gif
InBlock.gif                
// Specify the DELETE method.
InBlock.gif
                objRequest.Method = "DELETE";
InBlock.gif
InBlock.gif                
// Send the DELETE method request.
InBlock.gif
                objResponse = (System.Net.HttpWebResponse)objRequest.GetResponse();
InBlock.gif
InBlock.gif                
// Close the HttpWebResponse object.
InBlock.gif
                objResponse.Close();
InBlock.gif
InBlock.gif                
//Console.WriteLine("Item successfully deleted.")
InBlock.gif

ExpandedSubBlockEnd.gif            }

InBlock.gif            
catch(Exception e)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
throw new Exception("Can't delete the item" + e.ToString());
InBlock.gif
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// create a subfolder
InBlock.gif        
/// </summary>
ExpandedSubBlockEnd.gif        
/// <param name="strBody"></param>

InBlock.gif        public void CreateFolder(string folderName)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//string strSrcURI = ItemURL;
InBlock.gif
            try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
// Create the HttpWebRequest object.
InBlock.gif
                objRequest = (HttpWebRequest)HttpWebRequest.Create(Url + "/" + folderName);
InBlock.gif                
// Add the network credentials to the request.
InBlock.gif
                objRequest.Credentials = m_Session.Credentials;
InBlock.gif                
// Specify the method.
InBlock.gif
                objRequest.Method = "MKCOL";
InBlock.gif
InBlock.gif                objResponse 
= (System.Net.HttpWebResponse)objRequest.GetResponse();
InBlock.gif
InBlock.gif                
// Close the HttpWebResponse object.
InBlock.gif
                objResponse.Close();
InBlock.gif                
ExpandedSubBlockEnd.gif            }

InBlock.gif            
catch(Exception e)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
throw new Exception("Can't create the foder" + e.ToString());
ExpandedSubBlockEnd.gif            }
            
ExpandedSubBlockEnd.gif        }

InBlock.gif
//        public DataSet GetDataFromXmlDocument(XmlDocument xml)
InBlock.gif
//        {
InBlock.gif
//            XmlDocument xd = new XmlDocument();
InBlock.gif
//            xd.LoadXml("<myroot>" + FieldStr + "</myroot>");
InBlock.gif
//            XPathNavigator xpn = xd.CreateNavigator();
InBlock.gif
//            XPathNodeIterator ni = xpn.Select("/myroot/Field");
InBlock.gif
//            while (ni.MoveNext())
InBlock.gif
//            {
InBlock.gif
//                SpsExpendFieldData objFieldData = SpsExpendFieldData.Create(ni.Current.GetAttribute("Name",""),
InBlock.gif
//                    ni.Current.GetAttribute("ColName",""),
InBlock.gif
//                    0,
InBlock.gif
//                    ni.Current.GetAttribute("Type",""));
InBlock.gif
//                result.Add(objFieldData);
InBlock.gif
//            }
InBlock.gif
//            return result;
InBlock.gif
//        }
ExpandedSubBlockEnd.gif
    }

ExpandedBlockEnd.gif}

None.gif


None.gif WebExchange obj  =   new  WebExchange(WebDavSession.GetSession(ISoftStone.AccessExchange.WebDav.User.GetUser( " jianli " , " password " , " iisdnet " ),
None.gif                
" http://10.10.10.10/exchange/jianli/日历 " ));
None.gif
None.gif            System.Text.StringBuilder sb 
=   new  System.Text.StringBuilder();
None.gif            sb.Append(
"  <?xml version=\ " 1.0 \ " ?> " );
None.gif            sb.Append(
"  <D:searchrequest xmlns:D = \ " DAV:\ "  > " );
None.gif            sb.Append(
"  <D:sql> " );
None.gif            sb.Append(
"  SELECT \ " DAV:displayname\ "" );
None.gif            sb.Append(
"  ,\ " DAV:href\ "   " );
None.gif            sb.Append(
" ,\ " urn:schemas:calendar:dtstart\ "   " );
None.gif            sb.Append(
" ,\ " urn:schemas:calendar:dtend\ "   " );
None.gif            sb.Append(
"  ,\ " urn:schemas:calendar:location\ "" );
None.gif            sb.Append(
" ,\ " urn:schemas:calendar:busystatus\ "   " );
None.gif            sb.Append(
" ,\ " urn:schemas:httpmail:subject\ "" );
None.gif            sb.Append(
"  ,\ " urn:schemas:httpmail:htmldescription\ ""  );
None.gif            sb.Append(
"  FROM  \ " http: // 10.10.10.10/exchange/jianli/日历\"");
None.gif
            sb.Append( "  WHERE \ " urn:schemas:calendar:dtstart\ "  >= ' "   +   this .TBBeginTime.Text.Trim()  +   " " );
None.gif            sb.Append(
"  AND \ " urn:schemas:calendar:dtstart\ "  &lt; '2006-01-01'  " );
None.gif            sb.Append(
"  </D:sql></D:searchrequest>  " );


None.gif DataSet ds  =   new  DataSet();
None.gif            DataTable db 
=   new  DataTable();
None.gif            ds.Tables.Add(db);
None.gif            
None.gif            ds.Tables[
0 ].Columns.Add( " displayname " ,System.Type.GetType( " System.String " ));
None.gif            ds.Tables[
0 ].Columns.Add( " href " ,System.Type.GetType( " System.String " ));
None.gif            ds.Tables[
0 ].Columns.Add( " dtstart " ,System.Type.GetType( " System.DateTime " ));
None.gif            ds.Tables[
0 ].Columns.Add( " dtend " ,System.Type.GetType( " System.DateTime " ));
None.gif            ds.Tables[
0 ].Columns.Add( " location " ,System.Type.GetType( " System.String " ));
None.gif            ds.Tables[
0 ].Columns.Add( " busystatus " ,System.Type.GetType( " System.String " ));
None.gif            ds.Tables[
0 ].Columns.Add( " subject " ,System.Type.GetType( " System.String " ));
None.gif            ds.Tables[
0 ].Columns.Add( " htmldescription " ,System.Type.GetType( " System.String " ));
None.gif            
// ds.Tables[0].Columns.Add("href",System.Type.GetType("System.String"));
None.gif

None.gif            XmlDocument xd;
None.gif            
// xd.Load(@"C:\jjj.xml");
None.gif
            xd  =  obj.SearchItems(sb.ToString());
None.gif        
None.gif
None.gif            XPathNavigator xpn 
=  xd.CreateNavigator();
None.gif            XPathExpression expr 
=  xpn.Compile( " //a:multistatus/a:response/a:propstat/a:prop " );
None.gif            XmlNamespaceManager nsmgr 
=   new  XmlNamespaceManager(xpn.NameTable);
None.gif            nsmgr.AddNamespace(
" a " , " DAV: " );
None.gif            nsmgr.AddNamespace(
" d " , " urn:schemas:calendar: " );
None.gif            expr.SetContext(nsmgr);
None.gif
None.gif            XPathNodeIterator ni 
=  xpn.Select(expr);
None.gif            Response.Write(ni.Count);
None.gif            
while  (ni.MoveNext())
ExpandedBlockStart.gifContractedBlock.gif            
dot.gif {
InBlock.gif                
InBlock.gif                
//if(ni.Current.Value != "")
ExpandedSubBlockStart.gifContractedSubBlock.gif
                dot.gif{
InBlock.gif                    DataRow row 
= ds.Tables[0].NewRow();
InBlock.gif                    XPathNodeIterator mi 
= ni.Current.SelectChildren("displayname","DAV:");
InBlock.gif                    
while(mi.MoveNext())
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        row[
"displayname"= mi.Current.Value;
InBlock.gif                        
//Response.Write("[" + mi.Current.Value + "]");
ExpandedSubBlockEnd.gif
                    }

InBlock.gif                    mi 
= null;
InBlock.gif                    mi 
= ni.Current.SelectChildren("href","DAV:");
InBlock.gif                    
while(mi.MoveNext())
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        row[
"href"= mi.Current.Value;
InBlock.gif                        
//Response.Write("[" + mi.Current.Value + "]");
ExpandedSubBlockEnd.gif
                    }

InBlock.gif                    mi 
= null;
InBlock.gif                    mi 
= ni.Current.SelectChildren("dtstart","urn:schemas:calendar:");
InBlock.gif                    
while(mi.MoveNext())
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        row[
"dtstart"= (Convert.ToDateTime(mi.Current.Value));
InBlock.gif                        
//Response.Write("[" + mi.Current.Value + "]");
ExpandedSubBlockEnd.gif
                    }

InBlock.gif                    mi 
= null;
InBlock.gif                    mi 
= ni.Current.SelectChildren("dtend","urn:schemas:calendar:");
InBlock.gif                    
while(mi.MoveNext())
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        row[
"dtend"= (Convert.ToDateTime(mi.Current.Value));//.AddHours(8);
InBlock.gif                        
//Response.Write("[" + mi.Current.Value + "]");
ExpandedSubBlockEnd.gif
                    }

InBlock.gif                    mi 
= null;
InBlock.gif                    mi 
= ni.Current.SelectChildren("location","urn:schemas:calendar:");
InBlock.gif                    
while(mi.MoveNext())
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        row[
"location"= mi.Current.Value;
InBlock.gif                        
//Response.Write("[" + mi.Current.Value + "]");
ExpandedSubBlockEnd.gif
                    }

InBlock.gif                    mi 
= null;
InBlock.gif                    mi 
= ni.Current.SelectChildren("busystatus","urn:schemas:calendar:");
InBlock.gif                    
while(mi.MoveNext())
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        row[
"busystatus"= mi.Current.Value;
InBlock.gif                        
//Response.Write("[" + mi.Current.Value + "]");
ExpandedSubBlockEnd.gif
                    }

InBlock.gif                    mi 
= null;
InBlock.gif                    mi 
= ni.Current.SelectChildren("subject","urn:schemas:httpmail:");
InBlock.gif                    
while(mi.MoveNext())
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        row[
"subject"= mi.Current.Value;
InBlock.gif                        
//Response.Write("[" + mi.Current.Value + "]");
ExpandedSubBlockEnd.gif
                    }

InBlock.gif                    mi 
= null;
InBlock.gif                    mi 
= ni.Current.SelectChildren("htmldescription","urn:schemas:httpmail:");
InBlock.gif                    
while(mi.MoveNext())
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        row[
"htmldescription"= mi.Current.Value;
InBlock.gif                        
//Response.Write("[" + mi.Current.Value + "]");
ExpandedSubBlockEnd.gif
                    }

InBlock.gif                    ds.Tables[
0].Rows.Add(row);
ExpandedSubBlockEnd.gif                }

InBlock.gif
InBlock.gif                
//                SpsExpendFieldData objFieldData = SpsExpendFieldData.Create(ni.Current.GetAttribute("Name",""),
InBlock.gif                
//                    ni.Current.GetAttribute("ColName",""),
InBlock.gif                
//                    0,
InBlock.gif                
//                    ni.Current.GetAttribute("Type",""));
InBlock.gif                
//                result.Add(objFieldData);
InBlock.gif
                
ExpandedBlockEnd.gif            }

exchange日历中的字段列表

最近工作中遇到些烦心的事,郁闷了好几天总也开心不起来,现在想通了

开心就好

转载于:https://www.cnblogs.com/umlchina/archive/2005/04/25/144768.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值