c# - How to check the System.Net.Mail.SmtpClient.Credential -
i want check if have input right senderemail , mailpassword.what should do?the code :
//邮箱地址//emailaddress string server = combobox.text; string sendermail = emailname.text.tostring().trim()+server; messagebox.show("邮箱地址为:" + sendermail); //邮箱密码//emailpassword string mailpassword = emailpassword.text.tostring().trim(); //发送服务器//senderserver server = server.substring(1); string sendserver = "smtp."+server; messagebox.show(sendserver); //新建smtp客户端实例//create smtpclient system.net.mail.smtpclient client = new system.net.mail.smtpclient(sendserver, 25); client.credentials = new system.net.networkcredential(sendermail, mailpassword); if (?????) { messagebox.show("success!"); }
to check if senderemail correct can use mailaddress class
try { new mailaddress(senderemail); } catch (formatexception ex) { //the email address not correct }
Comments
Post a Comment