EWS操作exchange郵件伺服器收發郵件
參考資料: http://www.dotblogs.com.tw/wadehuang36/archive/2012/07/04/ews-first.aspx
本範例的主要功能是尋找未讀郵件並下載附件、完成更新成已讀並行動資料夾
01 |
internal class Program |
02 |
{ |
03 |
private static void Main( string []
args) |
04 |
{ |
05 |
ExchangeService
es = new ExchangeService(ExchangeVersion.Exchange2007_SP1); //版本預設值最新版 |
06 |
es.Credentials
= new WebCredentials( "username" , "password" , "domain" ); |
07 |
//es.Credentials
= new ClientCertificateCredentials(x509); 也可以使用憑證登入 |
08 |
10 |
11 |
Folder
processedFolder = GetFolder(es); |
12 |
SearchFilter
search = new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false ); //使用欄位搜尋 |
13 |
//string
search = "From:Wade AND Subject:EWS"; //也支援搜尋語法,但語法沒有IsRead欄位 |