2014-12-16 230 views
0

받은 편지함에서 삭제 된 폴더로 메일을 이동하려고합니다. 그러나 프로그램을 실행할 때 위의 오류 메시지가 나타납니다. 이 문제를 해결하는 데 도움주세요. 다음은 서버가 서버에있는 방법은 귀하의 HTTP 요청 유형과 일치하지 않습니다 제외 할 때이 오류가 그림으로 오는 내 코드원격 서버에서 오류 405 메서드를 반환했습니다.

string mailboxURI = "URL//"; 

     string username = "username"; 
     string password = "Password"; 
     string domain = "domain name"; 

     Console.WriteLine("Connecting to Exchange Server...."); 
     try 
     { 
      NetworkCredential credential = new NetworkCredential(username, password, domain); 
      ExchangeClient client = new ExchangeClient(mailboxURI, credential); 

      ExchangeMailboxInfo mailboxInfo = client.GetMailboxInfo(); 

      // List all messages from Inbox folder 
      Console.WriteLine("Listing all messages from Inbox...."); 
      ExchangeMessageInfoCollection msgInfoColl = client.ListMessages(mailboxInfo.InboxUri); 
      foreach (ExchangeMessageInfo msgInfo in msgInfoColl) 
      { 
       // Move message to "Deleted" folder, after processing certain messages 
       // based on some criteria 
       if (msgInfo.Date != DateTime.Today) 
       { 
        // Move it 
        client.MoveItems(msgInfo.UniqueUri, client.MailboxInfo.RootUri + "/Deleted/" + msgInfo.Subject); 
        Console.WriteLine("Message moved...." + msgInfo.Subject); 
       } 
       else 
       { 
        Console.WriteLine("Not moved:" + msgInfo.Subject); 
       } 
      } 
     } 
     catch (Exception ex) 
     { 
      Console.WriteLine("Error:"+ex.Message); 
      Console.Read(); 
     } 
    } 
+0

뭔가 UR URL에 문제가 있습니다 – Neel

답변

3

입니다.

예 : 서버가 http GET 메소드를 기대하지만 코드가 POST 메소드를 사용하여 서버 또는 viceversa와 comunicate합니다.

코드에서 메서드 유형을 변경하고자 할 수 있습니다.

건배 아난