Send email confirmation in VB.NET

I have a web site done in ASP.NET with VB.NET.  I need to send an email confirmation of an online order after the customer checks out.  I have some code (see snippet) but MS Visual Web Developer doesn't like the MailMessage and several other parts, saying they're obsolete.  Will someone please tell me what the current (looking for .NET 3.5, but 2.0 may do) code for that?  I call the Sub on page-load.
Public Shared Sub SendMailMessage(ByVal from As String, ByVal recepient As String, ByVal bcc As String, ByVal cc As String, ByVal subject As String, ByVal body As String)
 
Dim mMailMessage As New MailMessage()
mMailMessage.From = New MailAddress(from)
mMailMessage.To.Add(New MailAddress(recepient))
 
        If Not bcc Is Nothing And bcc <> String.Empty Then
            mMailMessage.Bcc.Add(New MailAddress(bcc))
        End If
 
        If Not cc Is Nothing And cc <> String.Empty Then
            mMailMessage.CC.Add(New MailAddress(cc))
        End If
 
mMailMessage.Subject = subject
mMailMessage.Body = body
 
mMailMessage.IsBodyHtml = True
mMailMessage.Priority = MailPriority.Normal
 
Dim mSmtpClient As New SmtpClient()
mSmtpClient.Send(mMailMessage)
 
End Sub

Open in new window

OVC-it-guyAsked:
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.

ladarlingCommented:
You need to change your import from System.Web.Mail to System.Net.Mail.
The two objects you will most likely be interested are:
System.Net.Mail.MailMessage
System.Net.Mail.SmtpClient
http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx
 
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
OVC-it-guyAuthor Commented:
Let me try that and fill in the parameters.
0
OVC-it-guyAuthor Commented:
Filled everything in, placed a test order and when the email routine was triggered I get an error "SMTP host was not specified," referring to the line,
mSmtpClient.Send(mMailMessage)
 
0
OVC-it-guyAuthor Commented:
I seem to recall something about setting that in the web.config file.  Do you know, can you tell me what I am missing / should have?
0
OVC-it-guyAuthor Commented:
I remember it being something like this:

<system.net>
    <mailSettings>
      <smtp deliveryMethod="Network" from="me@omahavaccine.com">
        <network defaultCredentials="true" host="localhost" port="25" userName="myusername" password="mypassword"/>
      </smtp>
    </mailSettings>
  </system.net>
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.