c# - The remote server returned an error 405 method not allowed -
i trying move mails inbox deleted folder. when run program getting above error message. please solve this. here code
string mailboxuri = "url//"; string username = "username"; string password = "password"; string domain = "domain name"; console.writeline("connecting exchange server...."); try { networkcredential credential = new networkcredential(username, password, domain); exchangeclient client = new exchangeclient(mailboxuri, credential); exchangemailboxinfo mailboxinfo = client.getmailboxinfo(); // list messages inbox folder console.writeline("listing messages inbox...."); exchangemessageinfocollection msginfocoll = client.listmessages(mailboxinfo.inboxuri); foreach (exchangemessageinfo msginfo in msginfocoll) { // move message "deleted" folder, after processing messages // based on criteria if (msginfo.date != datetime.today) { // move 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(); } }
this error comes picture when server excepting method on server not matching http request type.
for eg. server expecting http method code using post method comunicate server or viceversa.
you might want change type of method in code.
cheers anant
Comments
Post a Comment