MailMessage message = new MailMessage("[email protected]", mailto, mailsubject, mailbody);
            SmtpClient client = new SmtpClient("smtp.126.com", 25);
            client.Credentials = new NetworkCredential("yy123", "xt9978327");
            try
            {
                client.Send(message);
            }catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
邮件有时能发送成功有时不成功 怎么才能提示一下 到底发送成功还是没成功呢? 
请教一下!

解决方案 »

  1.   

    If you receive an SmtpException exception, check the StatusCode property to find the reason the operation failed. The SmtpException can also contain an inner exception that indicates the reason the operation failed. 
      

  2.   

    您说的大概意思 我好像明白了  可是我想说的的 MailMessage 执行发送邮件时  不能给与一定的提示 例如 执行添加的时候 可以返回一个int值 进行判断什么 的 
    像这个操作 我就只能判断异常信息吗 ?晕了 请指教