K
kimiraikkonen
Hello experts,
I've been already working on a project and also asked and i've managed
to create a basic Gmail mail sender, but i want to add a progressbar
that shows "sending is in progress" but when i add the
progressbar1.show() when sending then progressbar.hide() after sending
finishes, as known well progressbar is shown after sending is finished
because the main form is in use.
So, must i add multi-threading function to show my progress bar at the
same while my mail is sending simultaneously? Where can i add the code
of that code?
Thanks:
Imports System.Net.mail
Public Class Form1
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click
Try
Dim message As New MailMessage(txtfrom.Text, txtto.Text,
txtsubject.Text, txtbody.Text)
Dim emailClient As New SmtpClient("smtp.gmail.com")
message.Priority = MailPriority.High
Dim SMTPUserInfo As New System.Net.NetworkCredential(txtSMTPUser.Text
+ "@gmail.com",
txtSMTPPass.Text)
emailClient.UseDefaultCredentials = False
emailClient.Credentials = SMTPUserInfo
emailClient.Port = 587
emailClient.EnableSsl = True
emailClient.Send(message)
MsgBox("Mail was sent successfully",
MsgBoxStyle.Information, "Success!")
Catch ex As Exception
MsgBox("Mail couldn't be send" + vbNewLine + "Make sure
you entered correct username/password then try again later",
MsgBoxStyle.Exclamation, "Fail")
End Try
End Sub
End Class
I've been already working on a project and also asked and i've managed
to create a basic Gmail mail sender, but i want to add a progressbar
that shows "sending is in progress" but when i add the
progressbar1.show() when sending then progressbar.hide() after sending
finishes, as known well progressbar is shown after sending is finished
because the main form is in use.
So, must i add multi-threading function to show my progress bar at the
same while my mail is sending simultaneously? Where can i add the code
of that code?
Thanks:
Imports System.Net.mail
Public Class Form1
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click
Try
Dim message As New MailMessage(txtfrom.Text, txtto.Text,
txtsubject.Text, txtbody.Text)
Dim emailClient As New SmtpClient("smtp.gmail.com")
message.Priority = MailPriority.High
Dim SMTPUserInfo As New System.Net.NetworkCredential(txtSMTPUser.Text
+ "@gmail.com",
txtSMTPPass.Text)
emailClient.UseDefaultCredentials = False
emailClient.Credentials = SMTPUserInfo
emailClient.Port = 587
emailClient.EnableSsl = True
emailClient.Send(message)
MsgBox("Mail was sent successfully",
MsgBoxStyle.Information, "Success!")
Catch ex As Exception
MsgBox("Mail couldn't be send" + vbNewLine + "Make sure
you entered correct username/password then try again later",
MsgBoxStyle.Exclamation, "Fail")
End Try
End Sub
End Class