我有一個程序發送帶有附件的電子郵件,它在家中有良好的互聯網連接正常工作,但當我使用較慢的連接時超時。電子郵件超時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");