This topic includes the sample code to send email from ASP.Net(VB) code :
Sample Code :
<%@ Import Namespace="System.Net.Mail" %>
<script runat="server">
   Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Â
       Dim strFrom = "yourname@yourdomain.com"
       Dim strTo = "recipient_email@domain.com"
       Dim MailMsg As New MailMessage(New MailAddress(strFrom.Trim()), New MailAddress(strTo))
       MailMsg.BodyEncoding = Encoding.Default
       MailMsg.Subject = "This is a test email using VB.Net Code"
       MailMsg.Body = "This is a test email using VB.Net Code"
       MailMsg.Priority = MailPriority.High
       MailMsg.IsBodyHtml = True
Â
       Dim SmtpMail As New SmtpClient
       Dim basicAuthenticationInfo As New System.Net.NetworkCredential("smtp@yourdomain.com", "password")
       SmtpMail.Host = "smtp.yourdomain.com"
       SmtpMail.UseDefaultCredentials = False
       SmtpMail.Credentials = basicAuthenticationInfo
Â
       SmtpMail.Send(MailMsg)
       lblMessage.Text = "Mail Sent"   Â
     End Sub
</script>
<html>
<body>
   <form runat="server">
       <asp:Label id="lblMessage" runat="server"></asp:Label>
   </form>
</body>
Note :-Â You will require to make some changes in your script like SMTP server, email address & password etc.
Dev License: This installation of WHMCS is running under a Development License and is not authorized to be used for production use. Please report any cases of abuse to abuse@whmcs.com
Most Popular Articles
How to use Dundas Mailer?
A. Sending an Email with the QuickSend Method <% Dim objMailer 'Mailer control Set...
How to send email through CDONTS Email?
CDONTS stands for "Collaboration Data Objects for Windows NT Server" and as the name suggests it...
How to send emails through JMail?
We have installed JMail on our Windows shared servers. You can use following sample script to...
How to use ASPSMS?
Here is the ASP VB-Script example, intended to be used on an IIS (Internet Information Server)...
How to use Dundas Upload?
Dundas upload control is a flexible and reliable component allows you to accept, save, and...
Powered by WHMCompleteSolution