Public Sub sendmail()
' Sending Mail to Multiple Recipient
Dim mails As Net.Mail.MailMessage = New Net.Mail.MailMessage()
Try
mails.To.Add(txtemail.Text)
mails.From() = New MailAddress("Your mail id here")
mails.Subject() = txtsubject.Text
mails.IsBodyHtml = True
mails.Body = texteditor.Content
'Attaching the File
Dim attachFile As New Attachment(Server.MapPath("Attachfile.doc"))
mails.Attachments.Add(attachFile)
Dim SMTPServer As New SmtpClient("smtp.gmail.com")
SMTPServer.Port = 587
SMTPServer.Credentials = New System.Net.NetworkCredential("yourmailidhere@gmail.com", "password")
SMTPServer.EnableSsl = True
SMTPServer.Send(mails)
Catch ex As Exception
End Try
End Sub
No comments:
Post a Comment