I use asp.net and C # .net to send mail with large attachments (maximum 10 MB), which is the reason I can convert files, .txt, .doc, .xls file, it sends fine, but images and rar file damaged, what is the problem, please give me any suggestion,
My code
DataSet ds = SqlHelper.ExecuteDataset(con, "usp_GetEmailSettings", Session["UserID"].ToString());
message.To.Add(ds.Tables[0].Rows[0]["Email"].ToString());
message.CC.Add(ds.Tables[1].Rows[0]["EmailID"].ToString());
message.Subject = ds.Tables[0].Rows[0]["Email_Subject"].ToString();
message.From = new System.Net.Mail.MailAddress(ds.Tables[1].Rows[0]["EmailID"].ToString());
message.Body = ds.Tables[0].Rows[0]["Email_Body"].ToString() +
"<br/><br/> <font size='2.0em'>Submission Number : " +filename+"<br/> DBA Name : " +txtDBAName.Text + "<br/> Insured Name : " +TxtInsured.Text + "<br/> Additional Comments : " + txtcomment.Value ;
message.IsBodyHtml = true;
string attachId;
System.Net.Mail.Attachment at;
HttpFileCollection hfc = Request.Files;
if (hfc.Count > 0)
{
for (int i = 0; i < hfc.Count; i++)
{
HttpPostedFile hpf = hfc[i];
if (hpf.ContentLength > 0)
{
if (i == 0)
{
string[] ext = System.IO.Path.GetFileName(hpf.FileName).Split('.');
attachId = filename + "." + ext[1];
at = new System.Net.Mail.Attachment(fluuploader.FileContent, attachId);
}
else
{
string[] ext = System.IO.Path.GetFileName(hpf.FileName).Split('.');
attachId = filename + "(" + i + ")" + "." + ext[1];
at = new System.Net.Mail.Attachment(fluuploader.FileContent, attachId);
}
at.TransferEncoding = System.Net.Mime.TransferEncoding.SevenBit;
message.Attachments.Add(at);
}
}
}
smtp.Timeout = 9999999;
smtp.Send(message);
web.config my code
<httpRuntime executionTimeout="240" maxRequestLength="20480"/>
at.TransferEncoding = System.Net.Mime.TransferEncoding.SevenBit; I can give a comment on this line without transferring large files, but everything works fine, but I send large files with a maximum of 10mb, pls give me a suggestion
source
share