我有一个程序发送带有附件的电子邮件,它在家中有良好的互联网连接正常工作,但当我使用较慢的连接时超时。电子邮件超时C#
有谁知道我是否可以延长时间,以便通过较慢的网络发送。
我使用的代码是
Cursor.Current = Cursors.WaitCursor;
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress(FilePaths.Default.SquadronEmailAddress);
mail.To.Add(FilePaths.Default.Email);
mail.Subject = FilePaths.Default.SquadronNumber + " Gliding Training Return";
mail.Body = "Please find attached todays Training Return from " + FilePaths.Default.SquadronNumber +
". Please do not reply to this email address as its unmonitored. " +
"If you have any questions or require further information please contact the Adj on [email protected]";
mail.Attachments.Add(new Attachment(FilePaths.Default.GlidingTrainingReturnFolder + ("\\Gliding Training Return" + date.ToString("dd-MMM-yyyy") + ".pdf")));
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential(FilePaths.Default.SquadronEmailAddress, FilePaths.Default.DatabasePassword);
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
MessageBox.Show("Email Sent");