Take the 2-minute tour ×

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@hotmail.co.uk");
mail.Subject = "Emailed from C#";
mail.Body = "Emailed with attachment";
Attachment attachment;
attachment = new Attachment(@"C:\file.txt");
SmtpServer.Port = 587;
SmtpServer.Credentials = new NetworkCredential("email@hotmail.co.uk", "password");
SmtpServer.EnableSsl = true;
share|improve this question
What if you try to specify content type? –  Iaroslav Kovtunenko Oct 17 '11 at 11:05
May not apply, but beware of Hotmail's junk filter. In addition to the Junk Folder, I've also had it silently 'drop' emails I sent through code to @hotmail addresses, even without attachments. It's possible the larger attachment size triggered the spam filter? –  Widor Oct 17 '11 at 11:05
@IaroslavKovtunenko I'm not sure, how do I specify a content type? Thanks! –  Bali C Oct 17 '11 at 11:06
BTW, attachment should be disposed after use, though it is not relevant here. –  Iaroslav Kovtunenko Oct 17 '11 at 11:07
Check this: stackoverflow.com/questions/5258939/… –  Mohamed Abed Oct 17 '11 at 12:29
show 5 more comments

1 Answer

up vote 0 down vote accepted

Accepted answer is Mohamed's link to bug fix question - https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=30226

share|improve this answer
add comment

Your Answer


