Results 1 to 5 of 5

Thread: [RESOLVED] System.Web.Mail.MailMessage fails 1 in every 5 mails

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2003
    Posts
    56

    Resolved [RESOLVED] System.Web.Mail.MailMessage fails 1 in every 5 mails

    From my application which is running on a win2003 server, I send mail using .System.Web.Mail.MailMessage:

    Public Sub SendMail(ByVal FromText As String, _
    ByVal sendToText As String, ByVal SubjectText As String, _
    ByVal BodyText As String)
    If sendToText.ToString.Trim.Length >= 0 And FromText.ToString.Trim.Length > 0 Then
    myMessage = New MailMessage
    System.Web.Mail.SmtpMail.SmtpServer = "xxx.com"
    Try
    With myMessage
    .BodyFormat = MailFormat.Text
    .Priority = MailPriority.Normal
    .To = sendToText.ToString
    .From = FromText.ToString
    .Subject = SubjectText.ToString
    .Body = BodyText.ToString
    End With
    System.Web.Mail.SmtpMail.Send(myMessage)
    Catch ex As Exception
    MsgBox(ex.Message, MsgBoxStyle.Information)

    End Try


    Now what happens is, that there is an irregular CDO error message. The first time I run it, 4 messages are being sent and on number 5 I get a "Could not access CDO.message object" error. Then I send another 5 messages in a row, and number 3 would fail, or number 1. So no pattern at all.

    Anyone seen that behaviour before?
    Last edited by PVR; Jun 12th, 2006 at 01:20 PM. Reason: mailhub not hidden

  2. #2
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,547

    Re: System.Web.Mail.MailMessage fails 1 in every 5 mails

    Quote Originally Posted by PVR
    From my application which is running on a win2003 server, I send mail using .System.Web.Mail.MailMessage:

    Public Sub SendMail(ByVal FromText As String, _
    ByVal sendToText As String, ByVal SubjectText As String, _
    ByVal BodyText As String)
    If sendToText.ToString.Trim.Length >= 0 And FromText.ToString.Trim.Length > 0 Then
    myMessage = New MailMessage
    System.Web.Mail.SmtpMail.SmtpServer = "xxx.com"
    Try
    With myMessage
    .BodyFormat = MailFormat.Text
    .Priority = MailPriority.Normal
    .To = sendToText.ToString
    .From = FromText.ToString
    .Subject = SubjectText.ToString
    .Body = BodyText.ToString
    End With
    System.Web.Mail.SmtpMail.Send(myMessage)
    Catch ex As Exception
    MsgBox(ex.Message, MsgBoxStyle.Information)

    End Try


    Now what happens is, that there is an irregular CDO error message. The first time I run it, 4 messages are being sent and on number 5 I get a "Could not access CDO.message object" error. Then I send another 5 messages in a row, and number 3 would fail, or number 1. So no pattern at all.

    Anyone seen that behaviour before?

    could ur smtp server be blocking ur requests because ur trying to send to many at once?

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: System.Web.Mail.MailMessage fails 1 in every 5 mails

    For the sake of troubleshooting, add a small 3 second or 5 second timer to your loop and then try sending the emails out.

  4. #4

    Thread Starter
    Member
    Join Date
    Mar 2003
    Posts
    56

    Re: System.Web.Mail.MailMessage fails 1 in every 5 mails

    I just tried that, but no luck. On the second test, the mail even failed on the very first "send".

    First test : have 30 seconds between the first and second mail : second mail failed
    Second test: Failed on the first mail already

    Is there a way of actually seeing what the SMTP server responded? I could not see a "proper" error in any of the debug values


    Thanks for your help so far guys.

  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2003
    Posts
    56

    Re: System.Web.Mail.MailMessage fails 1 in every 5 mails

    Ok - the way I solved it was as follows:

    - I put a loop around the mailsend command which re-tries up to 5 times

    Whenever it fails, it now will work on the second or third retry.

    Thanks for your suggestions guys.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width