Mailbox Name Not Allowed. Sender Address Rejected. Not Logged In

Tried a lot to identify the root cause of this error but totally failed. Any suggestion will be highly helpful.

Try
    Dim Smtp_Server As New SmtpClient
    Dim e_mail As New MailMessage()
    Smtp_Server.UseDefaultCredentials = False
    Smtp_Server.Credentials = New Net.NetworkCredential(txtFrom.Text, txtPassword.Text)
    Smtp_Server.Port = cmbPort.Text

    Smtp_Server.EnableSsl = cbxSSL.Checked
    Smtp_Server.Host = cmbHost.Text

    e_mail = New MailMessage()
    e_mail.From = New MailAddress(txtFrom.Text)
    e_mail.To.Add(txtTo.Text)
    e_mail.Subject = "Auto Email"
    e_mail.IsBodyHtml = False
    e_mail.Body = "Hi, This is test mail."

    Smtp_Server.Send(e_mail)
    MsgBox("Mail Sent")


Catch error_t As Exception
    MsgBox(error_t.ToString)
End Try

Open in new window

SixthsenseAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantCommented:
What address did you send it to?
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
In many cases that error indicates that you're not been authenticated (i.e. your login credentials are not correct). Can you show the code you're using to send the email? Be sure to obfuscate any email or login information.
0
SixthsenseAuthor Commented:
Oops dont know how I missed to post the question without the code.

Here it is

Try
    Dim Smtp_Server As New SmtpClient
    Dim e_mail As New MailMessage()
    Smtp_Server.UseDefaultCredentials = False
    Smtp_Server.Credentials = New Net.NetworkCredential(txtFrom.Text, txtPassword.Text)
    Smtp_Server.Port = cmbPort.Text

    Smtp_Server.EnableSsl = cbxSSL.Checked
    Smtp_Server.Host = cmbHost.Text

    e_mail = New MailMessage()
    e_mail.From = New MailAddress(txtFrom.Text)
    e_mail.To.Add(txtTo.Text)
    e_mail.Subject = "Auto Email"
    e_mail.IsBodyHtml = False
    e_mail.Body = "Hi, This is test mail."

    Smtp_Server.Send(e_mail)
    MsgBox("Mail Sent")


Catch error_t As Exception
    MsgBox(error_t.ToString)
End Try

Open in new window

0
David Johnson, CD, MVPOwnerCommented:
you missed something
add this
  Smtp_Server.DeliveryMethod = SmtpDeliveryMethod.Network

Open in new window

and it works for me
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David Johnson, CD, MVPOwnerCommented:
asker was missing 1 line of code
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.