How to send email with vb.Net code

Import Files

Imports System.Net.Mail
Imports System.Net.Dns

Code Behind

        Dim ClientIP As String
        ClientIP = Request.UserHostAddress()

        Dim FileName As String = Server.MapPath("FolderName/FileSample.pdf")
        Dim message As New MailMessage
        message.From = New MailAddress("", "Name")
        message.To.Add(New MailAddress(
        message.CC.Add(New MailAddress(""))
        message.Subject = "Subject Text"
        message.IsBodyHtml = True
        message.Attachments.Add(New System.Net.Mail.Attachment(FileName))
        message.Body = "BODY HTML<br />**Sender Info**<br />Computer: " & ClientIP & "<br />Ip: " & Request.ServerVariables("REMOTE_ADDR").ToString

        Dim client As New SmtpClient

Related Posts

Comments are closed.