电子邮件附件大小限制
我目前正在 C# 中使用此代码将带有附件的文件通过电子邮件发送到我的 hotmail 地址。我运行了这个,在附加 800KB 文件时效果很好,但是当我尝试附加 12MB 文件时它就不行,我把它放在 try catch
中,但没有例外,就像它刚刚跳过它一样。 hotmail 的电子邮件附件大小限制为 25MB,这会影响电子邮件代码吗?或者通过代码执行此操作时是否有单独的限制?谢谢。
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.live.com");
mail.From = new MailAddress("[email protected]");
mail.To.Add("[email protected]");
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 protected]", "password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
I am currently using this code in C# to email a file to my hotmail address with an attachment. I ran this and it worked great when attaching a 800KB file, but when I try to attach a 12MB file it just won't do it, I put it in a try catch
but there were no exceptions, like it just skipped it. The email attachment size limit for hotmail is 25MB, would this affect the email code, or is there a separate limit when doing it through code? Thanks.
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.live.com");
mail.From = new MailAddress("[email protected]");
mail.To.Add("[email protected]");
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 protected]", "password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
接受的答案是 Mohamed 的错误修复问题链接 - https://connect.microsoft .com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=30226
Accepted answer is Mohamed's link to bug fix question - https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=30226