c# - Unable to test SmtpClient.TimeOut -


i using visual studio 2010, .net 4.0 , trying test smtpclient.timeout property , throw smtpexception. however, when set timeout property 1 millisecond, still sends email seems sending under millisecond find interesting when inspect object can see private member variable called timedout set true, indicating in fact timed out.

enter image description here

here code:

try {             mailmessage emailmsg = new mailmessage(this.emailfrom, this.emailto, this.emailsubject, msg);             //smtpclient emailclient = new smtpclient(this.emailserver);             smtpclient emailclient = new smtpclient();             emailclient.credentials = new system.net.networkcredential("username", "password");                   emailmsg.isbodyhtml = true;                 emailclient.timeout = properties.settings.default.smtptimeout;                 emailclient.timeout = 1;                  emailclient.send(emailmsg);                 sendingemail = true;              return sendingemail;         }         catch (exception ex)         {               // handle time out exception here.          } 

has ever seen or know better way test this? right hitting gmail's smtp.

i believe can use telnet. turn on telnet , use ip smtp server. not connect should timeout. have not tested this.

http://technet.microsoft.com/en-us/library/aa995718(v=exchg.65).aspx


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -