Sample 2 - ASP.Net form mail coding-System.Net.Mail Print

  • 0

ASP.Net form mail coding-System.Net.Mail

Please find the sample code for asp.net form mail coding.

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

<html>

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

'create the mail message
Dim mail As New MailMessage()

'set the addresses
mail.From = New MailAddress("FROM MAIL ID")
mail.To.Add("TO MAIL ID")

'set the content
mail.Subject = "This is an email"
mail.Body = "this is a sample body with html in it. <b>This is bold</b> <font color=#336699>This is blue</font>"
mail.IsBodyHtml = True

'send the message
Dim smtp As New SmtpClient("127.0.0.1")
smtp.Send(mail)
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