Pablo3728, on 12 Nov, 2009 - 04:18 AM, said:
Hi! Thank you mb2000inc! Well, the program works ok, can send mails, but the warnings are there. If you have other code, would be great!

Let me first ask you, is this part of a contact form or is this an automated message that you're sending out to people or yourself for some purpose? The code I have is for a contact form. See below:
Imports System.Web.Mail
Imports System.EventArgs
Imports System.Object
Imports System.Web.UI.Control
Partial Class ContactUs
Inherits System.Web.UI.Page
Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Click
Try
'Declarations for variables
Dim mailMessage As New System.Net.Mail.MailMessage
Dim strToAddress, strFristName, strLastName, strPhone, strEmail, strState, strHowHearOfUs, strComments As String
'Assign values to your variables
'Don't forget to change the "to address" - you can also assign this to a form control
strToAddress = "youraddress@yourdomain.com"
strFristName = txtFName.Text
strLastName = txtLName.Text
strEmail = txtEmail.Text
strPhone = txtPhone.Text
strState = dlState.SelectedValue
strHowHearOfUs = dlHowHear.SelectedValue
strComments = txtComments.Text
'Create The To, From , And subject... then Encode the body formatting.
mailMessage.From = New System.Net.Mail.MailAddress(strEmail.ToString)
mailMessage.To.Add(strToAddress)
mailMessage.Subject = "INSERT SUBJECT HERE ==> (X)"
mailMessage.IsBodyHtml = True
mailMessage.Body = ("<html><p><h2>The following person had filled out the request for contact form</h2></p><p>Their contact information is as follows: <br /><strong>First Name: </strong>" & strFName & "<br /><strong>Last Name: </strong>" & strLName & "<br /><strong>Email: </strong>" & _
strEmail & "<br /><strong>Phone Number: </strong>" & strPhone & "<br /><strong>State: </strong>" & strState & "<br /><strong>How they heard of us: </strong>" & strHowHear & "<br /><strong>Comments: </strong><br />" & strComments & "<br /><br />Please review the information and contact them as soon as possible.</p></html>")
'Send the Email
'DON'T FORGET TO CHANGE THE MAIL SERVER ADDRESS BELOW
Dim smtp As New System.Net.Mail.SmtpClient("PUT YOUR MAIL SERVER ADDRESS HERE")
smtp.Send(mailMessage)
Label8.Text = "Thank You. Your mail has been sent"
'Display a client-side popup, explaining that the email has been sent
ClientScript.RegisterStartupScript(Me.GetType(), "PUT A NAME HERE", String.Format("alert('Your message has successfully been sent to {0}');", strToAddress.Replace("'", "\'")), True)
Catch smtpEx As Net.Mail.SmtpException
'A problem occurred when sending the email message
ClientScript.RegisterStartupScript(Me.GetType(), "PUT A NAME HERE", String.Format("alert('There was a problem in sending the message: {0}');", smtpEx.Message.Replace("'", "\'")), True)
Catch generalEx As Exception
'Some other problem occurred
ClientScript.RegisterStartupScript(Me.GetType(), "PUT A NAME HERE", String.Format("alert('There was a general problem: {0}');", generalEx.Message.Replace("'", "\'")), True)
End Try
End Sub
End Class