电子邮件附件大小限制

时间:2011-10-17 11:02:24

标签: c# email attachment

我目前在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);

1 个答案:

答案 0 :(得分:0)