Skip to content

Instantly share code, notes, and snippets.

@Kaylen-Travis-Pillay
Created October 19, 2017 06:07
Show Gist options
  • Save Kaylen-Travis-Pillay/9e5d0920d2ae2388a659d0938a8efeef to your computer and use it in GitHub Desktop.
Save Kaylen-Travis-Pillay/9e5d0920d2ae2388a659d0938a8efeef to your computer and use it in GitHub Desktop.
'Sir, please not that they will have to enable unknown application management on the senders gmail account
'The port number and host uset here are for gmail accounts
Try
Dim Smtp_Server As New SmtpClient
Dim e_mail As New MailMessage()
Smtp_Server.UseDefaultCredentials = False
Smtp_Server.Credentials = New Net.NetworkCredential("senders_username", "senders_password")
Smtp_Server.Port = 587
Smtp_Server.EnableSsl = True
Smtp_Server.Host = "smtp.gmail.com"
e_mail = New MailMessage()
e_mail.From = New MailAddress("senders_email_address")
e_mail.To.Add("intended_recipient_address")
e_mail.Subject = "Adams Coffee Bar: Order Confirmation"
e_mail.IsBodyHtml = False
e_mail.Body = "body of email"
Smtp_Server.Send(e_mail)
Catch error_t As Exception
End Try
@Kaylen-Travis-Pillay
Copy link
Author

This can be used for both the windows forms application ( M1 & M2 ) and the website (M4). However please note that in order to send an email in the front end system ( windows forms app ) it would be advisable to have a background thread running the above code. This is to prevent the entire UI from halting until the email is sent.

@Kaylen-Travis-Pillay
Copy link
Author

If you have any issues let me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment