Amazon Affiliate

Saturday 18 May 2013

Sending Email with attachment in VB.Net


Sending Email with Attachment in VB.Net

           Dim mail As New MailMessage
            mail.Subject = "Subject of the message"
            mail.To.Add("receiver's mail id")  '
            mail.From = New MailAddress("Sender's mail id")
            mail.Body ="Message Body"
            Dim attachment As System.Net.Mail.Attachment
            attachment = New System.Net.Mail.Attachment("Name of attachment box")
            mail.Attachments.Add(attachment)
            Dim smtp As New SmtpClient("smtp.gmail.com")
            smtp.EnableSsl = True
            smtp.Credentials = New System.Net.NetworkCredential("Sender's mail id",       
            "password")
            smtp.Port = "587"
            smtp.Send(mail)
            MsgBox("Message Send Successfully", MsgBoxStyle.Information)

No comments:

Post a Comment