المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Send EMail with zip file/rar file



C# Programming
07-12-2009, 02:42 PM
how can i send an email with an Attachments of zip/rar file?

I write this code :

System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();

System.Net.NetworkCredential cred = new System.Net.NetworkCredential("username@gmail.com", "password");

mail.To.Add("username@gmail.com");
mail.Subject = "Subject";
mail.From = new System.Net.Mail.MailAddress("username@gmail.com");
mail.IsBodyHtml = true;
mail.Body = filename;
mail.Attachments.Add(new Attachment(@"c:\1.zip",MediaTypeNames.Application.Zip));
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Credentials = cred;
smtp.Port = 587;
smtp.Timeout = 1000000;
smtp.Send(mail);

The size of the file "1.zip" is 500kb and i get this message:
{"Exceeded storage al********. The server response was: 5.7.0 Our system detected an illegal attachment on your message. Please"}


Can someone please help to solve this issue?