我目前正在使用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);
可接受的答案是Mohamed的bug修复问题链接- https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=30226