I'm pretty new to .NET, but I after a user registers for my site I would like to send out a confirmation e-mail. I searched around for a good while looking for code and I came up with this. dim smtpServer as String smtpServer = "mail.mydomain.com" dim cdoSendUsingPort as Integer cdoSendUsingPort = 2 dim cdoBasic as Integer cdoBasic = 1 dim userName as String userName = "userName" dim password as String password = "password" dim msg As MailMessage = new MailMessage() msg.Subject = "Testing" msg.Body = "Hello World" msg.From = "something@something.com" msg.To = "something@something.com" msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", smtpServer) msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25) msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", cdoSendUsingPort) msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", cdoBasic) msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", userName) msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password) System.Web.Mail.SmtpMail.SmtpServer = smtpServer System.Web.Mail.SmtpMail.Send(msg) Code (markup): And I am receiving an error message that looks like this which is pointing to the last line - The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available I'm not too sure what that means, but any help or insight would be greatly appreciated. Thanks again, Flyers8985!
might be an idea to change some of the dummy values to real ones - especially line 2 to the name of your domain and msg.from to an address at your domain
Oh, I did. I just well, didn't want to throw some of the values in there, as I was testing it with personal e-mail addresses and such.
Seems like the code you are using is from an older version of .net. If your host has .net 2.0 your can try: Sub Authenticate() 'create the mail message Dim mail As New MailMessage() 'set the addresses mail.From = New MailAddress("me@mycompany.com") mail.To.Add("you@yourcompany.com") 'set the content mail.Subject = "This is an email" mail.Body = "this is the body content of the email." 'send the message Dim smtp As New SmtpClient("127.0.0.1") 'to authenticate we set the username and password properites on the SmtpClient smtp.Credentials = New NetworkCredential("username", "secret") smtp.Send(mail) End Sub 'Authenticate
Please note that if you use the new version of e-mail processing in .NET 2.0, you must use System.Net.Mail instead of the old System.Web.Mail.
Make sure your SMTP server does allow you to send e-mail from the mail server. You may need to login or pop before you send anything. Many SMTP servers do this to cut down on SPAM, etc.