Jun 17, 2015 08:54 AM
(This post was last modified: Jun 17, 2015 10:01 AM by Strintent.)
I know most people know how to do this but i looked for a way to do it when i first started vb so im posting it here.
How to email with an attachment:
Gmail:
Hotmail/Live:
How to email with an attachment:
Code
Imports System.Net.MailCode
Dim Mail As New MailMessage
Mail.Subject = "Subject"
Mail.To.Add("To email")
Mail.From = New MailAddress("Your email")
Mail.Body = ("Main text")
Dim attachment As System.Net.Mail.Attachment
attachment = New System.Net.Mail.Attachment("Path to file")
Mail.Attachments.Add(attachment)
Dim SMTP As New SmtpClient("smtp.gmail.com")
SMTP.EnableSsl = True
SMTP.Credentials = New System.Net.NetworkCredential("Username", "Password")
SMTP.Port = "587"
SMTP.Send(Mail)Hotmail/Live:
Code
Dim Mail As New MailMessage
Mail.Subject = "Subject"
Mail.To.Add("To email")
Mail.From = New MailAddress("Your email")
Mail.Body = ("Main text")
Dim attachment As System.Net.Mail.Attachment
attachment = New System.Net.Mail.Attachment("Path to file")
Mail.Attachments.Add(attachment)
Dim SMTP As New SmtpClient("smtp.Live.com")
SMTP.EnableSsl = True
SMTP.Credentials = New System.Net.NetworkCredential("Username", "Password")
SMTP.Port = "587"
SMTP.Send(Mail)

