Last post Aug 24, 2010 10:27 AM by holderag
Aug 18, 2010 08:06 AM|holderag|LINK
I am getting an error when sending email via asp.net. The error is "Mailbox unavailable. The server response was: 5.1.1...User unknown."
However, the email is getting sent. Why is asp.net returning this error?
I'm using VS 2008, vb.net, running 2.0 framework. This happens regardless of whether I'm testing my application from my local machine or running production version. Also, I can send a batch of emails and get the error for some but not all.
I would like to be able to count of the error messages really being accurate, so this situation is unhelpful to our users, because they will start to just ignore all error messages.
Aug 18, 2010 08:39 AM|rajesh_patil|LINK
configur mail box using smtp client so u get accurate msgs. if ur r still getting err then plz upload code
Aug 20, 2010 07:59 AM|holderag|LINK
I'm using smtp client.
Here is code snippet:
....'here I fill a dataset with emails to be sent
......'then I roll through the dataset and try to send emails, catching any errors and continuing.
For i = 0 To ds.Tables("AllRegis").Rows.Count - 1
'this catches a send problem, puts error on page and in email, and allows process to continue
tempMSG2.Append("Email sent to: " & ds.Tables("AllRegis").Rows(i)("regisFirstName") & " " & ds.Tables("AllRegis").Rows(i)("regisLastName") & " at " & ds.Tables("AllRegis").Rows(i)("RegisEmail"))
Catch ex As Exception
tempPageMSG.Append("Email: " & ds.Tables("AllRegis").Rows(i)("RegisEmail") & " - Email notification could not be sent. EX: " & ex.Message)
tempMSG2.Append("Email: " & ds.Tables("AllRegis").Rows(i)("RegisEmail") & " - Email notification could not be sent. EX: " & ex.Message)
Aug 24, 2010 09:19 AM|atconway|LINK
You didn't really provide the code that shows sending the email, but rather the exception handling logic. Here is some stable VB.NET SMTP code, that you might want to compare with your code. Beyond this, it might be a configuration issue with the SMTP
server and not the code itself.
'Create a MailMessage object passing the To and From values to the constructor
Dim MailMsg As New MailMessage(New MailAddress("FromSomebody@gmail.com"), New MailAddress("ToSomeBody@gmail.com"))
'Configure addiitional properties of the MailMsg object
MailMsg.BodyEncoding = System.Text.Encoding.Default
MailMsg.Subject = "Test Email"
MailMsg.Body = "Hello this is a test"
'SMTP Client object to send the MailMessage object
Dim SmtpMail As New SmtpClient
SmtpMail.Host = "smtp.server.test"
'Send the completed MailsMsg object
SmtpMail = Nothing
Aug 24, 2010 10:27 AM|holderag|LINK
It appears the issue is somewhere with our mail servers because I changed the mail server I was using and it doesn't throw the error any more. Being programmer and not network guru, I don't understand the details. But there it is.
Thanks for your help.