Hello everyone!
I found on the web a class that send a mail with gmail account:
and it's work great!!!Code:Public Class MailSender Public Sub SendMail() Try Dim SmtpServer As New System.Net.Mail.SmtpClient() Dim mail As New System.Net.Mail.MailMessage() SmtpServer.Credentials = New Net.NetworkCredential("[my gmail]@gmail.com", "[my password]") SmtpServer.Port = 587 SmtpServer.Host = "smtp.gmail.com" SmtpServer.EnableSsl = True mail = New System.Net.Mail.MailMessage() mail.From = New System.Net.Mail.MailAddress("[my gmail]") mail.To.Add("[other mail]") mail.Subject = "Test Mail" mail.Body = "This is for testing SMTP mail from GMAIL" SmtpServer.Send(mail) MsgBox("mail send") Catch ex As Exception MsgBox(ex.ToString) End Try End Sub End Class
but there is one problem
when i create a button perform the class, the whole program get stuck for a while until the mail send
can i do something to make the class run on background?
Code:Public Class frmSender Dim m As New MailSender Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click m.SendMail() End Sub End Class


1Likes
LinkBack URL
About LinkBacks




Reply With Quote




Bookmarks