Sample 1 - ASP.Net form mail coding-System.Web.Mail Print

  • 0

ASP.Net form mail coding :

Please note that the sample Asp.Net form mail coding

<%@ Import Namespace="System.Web.Mail" %>

<html>

<script language="VB" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)

Dim msg as New MailMessage()

msg.To = "test@yourdomainname.com"
msg.From = "contact@yourdomainname.com"
msg.Subject = "test"
'msg.BodyFormat = MailFormat.Html
msg.BodyFormat = MailFormat.Text
msg.Body = "hi"

SmtpMail.SmtpServer = "localhost"

SmtpMail.Send(msg)
msg = Nothing
lblMsg.Text = "An Email has been send to " & "test@yourdomainname.com"

End Sub
</script>

<body style="font: 10pt verdana">
<form runat=server>
<asp:Label id=lblMsg runat=Server /> </form>
</body>
</html>

 


 


Was this answer helpful?

« Back