把错误的邮件名,发出去了.outlook返回了错误信息的.我的程序怎么也读取相应的信息了?

解决方案 »

  1.   

    try
    {
    //send code
    }
    catch(exception ee)
    {
    messagebox.show(ee.message);
    }
    ``
      

  2.   

    我想我的程序给126.com 一个邮件  bukenengcunzai@126 这个邮件在126.com实际不存在的话,
    我发的邮件也发送成功了,可是实际没有发出去的.
      

  3.   

    用foxmail,outlook等程序发一个邮件到126.com,会返回发送错误的信息,我想我的程序在发完邮件后,读取信息,判断我发的邮件是否发成功了这样
      

  4.   

    给bukenengcunzai@126发邮件,send时,会出异常的吧
    [email protected]发邮件,就不知道了
      

  5.   

    bukenengcunzai@126  给他发不出异常呢~~
      

  6.   

    你看看這個網址吧,不過是vb.net的,現在不是很容易轉成C#的嗎!  Public Shared Function SendMail(ByVal message As MailMessage) As Boolean
                Dim adminEmail As String = "[email protected]"
                '(管理员的邮箱) 
                message.BodyEncoding = Encoding.GetEncoding(936)
                message.SubjectEncoding = Encoding.GetEncoding(936)
                message.IsBodyHtml = True
                ' create a smpt client 
                Dim client As New SmtpClient(_SMTP_SERVER)
                Dim nc As New NetworkCredential(_SMTP_USER_NAME, _SMTP_USER_PASSWORD)
                ' Add credentials if the SMTP server requires them. 
                client.Credentials = nc
                Dim succeed As Boolean = False
                ' send mail 
                Try
                    'send message 
                    client.Send(message)
                    succeed = True
                Catch e As SmtpFailedRecipientsException
                    ' message 无法传递给 System.Net.Mail.MailMessage.To、System.Net.Mail.MailMessage.CC 
                    '或 System.Net.Mail.MailMessage.BCC 中的一个或多个收件人 
                    Dim sb As New StringBuilder()
                    sb.AppendLine("系统退信!")
                    sb.AppendLine("<br/>")
                    sb.AppendLine("发送到以下地址的邮件失败:")
                    sb.AppendLine("<br/>")
                    For Each ex As Exception In e.InnerExceptions
                        sb.AppendLine(ex.Message.Replace("<", "<br/>给").Replace(">:", "的发送的邮件不能抵达<br/>"))
                        sb.AppendLine("<br/>")
                    Next
                    sb.AppendLine("<br/>")
                    sb.AppendLine("<br/>")
                    sb.AppendFormat("发送时间:{0}", DateTime.Now)                SendMail(adminEmail, message.From.Address, Nothing, "部分收件人不能抵达", sb.ToString(), Nothing)
                    succeed = True
                Catch e As SmtpFailedRecipientException
                    Dim sb As New StringBuilder()
                    Dim failedEmail As String = e.FailedRecipient.Replace("<", "给").Replace(">", "的发送的邮件不能抵达")
                    sb.AppendLine("系统退信!")
                    sb.AppendLine("<br/>")
                    sb.AppendLine(failedEmail)
                    sb.AppendLine("<br/>")
                    sb.AppendLine(e.Message.Replace("<", "").Replace(">", ""))
                    sb.AppendLine("<br/>")
                    sb.AppendLine("<br/>")
                    sb.AppendFormat("发送时间:{0}", DateTime.Now)                SendMail(adminEmail, message.From.Address, Nothing, failedEmail, sb.ToString(), Nothing)
                    succeed = True
                Catch e As ArgumentNullException
                    'System.Net.Mail.MailMessage.From 为 null。- 或 -System.Net.Mail.MailMessage.To 为 null。- 或 - message 为 null。 
                    Throw e
                Catch e As ArgumentOutOfRangeException
                    'System.Net.Mail.MailMessage.To、System.Net.Mail.MailMessage.CC 和 System.Net.Mail.MailMessage.BCC 中没有收件人。 
                    Throw e
                Catch e As SmtpException
                    '连接到 SMTP 服务器失败。- 或 -身份验证失败。- 或 -操作超时。 
                    Throw e
                Catch e As Exception
                    '其他异常 
                    Throw e
                End Try
                message.Dispose()
                Return succeed
            End Function
       
      

  7.   

    try 
    { } 
    catch(exception ee) 
    { } 
     不行吗?
      

  8.   

    一般情况下是不会出现这种情况的。如果出现了说明邮箱是有BUG的。而且你也没有必要去刻意的改变的啊!
    我刚才按照你的方法测试了一下。但是结果好像不会发送成功的啊!你点击发送的时候他会提示这个界面结果是会提示的啊
      

  9.   

    汗,忘記給網址了:
    如下:http://hi.baidu.com/ph%5Ffairy/blog/item/74dfeeecd13a334978f055ed.html
      

  10.   

    现在126的邮箱还能用c#发送邮件么?
    pop功能被屏闭了。