954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Asp.net code for sending email

This is my code. But there are 3 errors in it.
1st Error: Dim message As New MailMessage()
2nd Error: SmtpMail.SmtpServer = mailServer
3rd Error: SmtpMail.Send(message)

Can someone teach me how to configure and correct the code?


Imports System.Web.Mail

Partial Class ReferaFriend
Inherits System.Web.UI.Page

Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdSubmit.Click

Dim webMasterEmail As String = "zombiez_zombiez@hotmail.com"
Dim emailSubject As String = "ASP.NET Secrets Email from website at " + DateTime.Now.ToString()
Dim mailServer As String = "jim_lams@hotmail.com"

'email code found below
Dim message As New MailMessage()

message.From = webMasterEmail
message.To = webMasterEmail
message.Subject = emailSubject
message.Body = "Email sent from" + txtEmailAddress.Text
message.Body += vbCrLf + txtMessage.Text
SmtpMail.SmtpServer = mailServer

SmtpMail.Send(message)
Response.Write("Message Sent!")
End Sub
End Class

vinlam
Newbie Poster
8 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You