E
eruth
Hi all,
I'm trying to send an e-mail from a vb.net web form. I can create the
message, but when it comes to actually sending it I get the following
error. "Mailbox name not allowed. The server response was: Server
policy dictates you must authenticate first "
So far as I can tell, my code is doing what it's meant to, but I'd
appreciate someone casting an eye over it to make sure. This is based
on a couple of examples found through google.
<code>
Dim Message As MailMessage = New MailMessage()
Dim Smtp As New SmtpClient()
Dim SmtpUser As New System.Net.NetworkCredential()
'-- Build Message
Message.From = New MailAddress("(e-mail address removed)", "Me")
Message.To.Add(New MailAddress("(e-mail address removed)", "you"))
Message.IsBodyHtml = False
Message.Subject = "test"
Message.Body = "This is a test"
'-- Define Authenticated User
SmtpUser.UserName = "user"
SmtpUser.Password = "password"
SmtpUser.Domain = "mydomain.co.uk"
'-- Send Message
Smtp.UseDefaultCredentials = False
Smtp.Credentials = SmtpUser
Smtp.Host = "mydomain.co.uk"
Smtp.Port = 25
Smtp.DeliveryMethod = SmtpDeliveryMethod.Network
Smtp.Send(Message)
</code>
I'm trying to send an e-mail from a vb.net web form. I can create the
message, but when it comes to actually sending it I get the following
error. "Mailbox name not allowed. The server response was: Server
policy dictates you must authenticate first "
So far as I can tell, my code is doing what it's meant to, but I'd
appreciate someone casting an eye over it to make sure. This is based
on a couple of examples found through google.
<code>
Dim Message As MailMessage = New MailMessage()
Dim Smtp As New SmtpClient()
Dim SmtpUser As New System.Net.NetworkCredential()
'-- Build Message
Message.From = New MailAddress("(e-mail address removed)", "Me")
Message.To.Add(New MailAddress("(e-mail address removed)", "you"))
Message.IsBodyHtml = False
Message.Subject = "test"
Message.Body = "This is a test"
'-- Define Authenticated User
SmtpUser.UserName = "user"
SmtpUser.Password = "password"
SmtpUser.Domain = "mydomain.co.uk"
'-- Send Message
Smtp.UseDefaultCredentials = False
Smtp.Credentials = SmtpUser
Smtp.Host = "mydomain.co.uk"
Smtp.Port = 25
Smtp.DeliveryMethod = SmtpDeliveryMethod.Network
Smtp.Send(Message)
</code>