我目前在C#中使用此代码通过附件将文件通过电子邮件发送到我的Hotmail地址。我运行它并且在附加800KB文件时效果很好,但是当我尝试附加一个12MB文件时它就不会这样做了,我把它放在try catch
但是没有例外,就像它刚跳过一样它。 hotmail的电子邮件附件大小限制为25MB,这会影响电子邮件代码,还是通过代码执行时会有单独的限制?感谢。
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.live.com");
mail.From = new MailAddress("email@hotmail.co.uk");
mail.To.Add("receiving@hotmail.co.uk");
mail.Subject = "Emailed from C#";
mail.Body = "Emailed with attachment";
Attachment attachment;
attachment = new Attachment(@"C:\file.txt");
mail.Attachments.Add(attachment);
SmtpServer.Port = 587;
SmtpServer.Credentials = new NetworkCredential("email@hotmail.co.uk", "password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
答案 0 :(得分:0)
接受的答案是Mohamed的错误修复问题链接 - https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=30226