我希望在发送自动生成的电子邮件时有一个进度条但我收到错误。请帮我解决这个问题。任何类型的回应都非常感谢。
我不知道自己是否走在正确的道路上,我是C#的初学者,只是依赖在线指南。
此行有错误
private void btnSend_Click(object sender, EventArgs e)
{
//Cursor.Current = Cursors.WaitCursor;
try
{
MailMessage loginInfo = new MailMessage();
string em = "angelicasarimo15@gmail.com";
loginInfo.To.Add(em.ToString());
loginInfo.From = new MailAddress("vicserna1997@gmail.com");
loginInfo.Subject = "Requesting Supplies";
loginInfo.Body = "We want another supplies for blah blah blah" + System.Environment.NewLine +
"This is a system generated email.";
loginInfo.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.Credentials = new System.Net.NetworkCredential("vicserna1997@gmail.com", "*Pass*");
smtp.Send(loginInfo);
MessageBox.Show("Email has been sent!", "Sent", MessageBoxButtons.OK);
progressBar1.Visible = true;
progressBar1.Style = ProgressBarStyle.Marquee;
System.Threading.Thread thread =
new System.Threading.Thread(new System.Threading.ThreadStart(btnSend_Click));
thread.Start();
}
catch
{
MessageBox.Show("Message not sent please check you internet connection", "Not Sent", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
}
}
String getBaseUrl(HttpServletRequest req) {
return req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort() + req.getContextPath();
}