Click here to Skip to main content
15,846,727 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am sending email from site. This email contains an attachment.
.These attachments is file existing on folder called upload
this is the code for generate attachment list:
C#
List _attchmentlist = new List(); 
foreach (PersonalFile row in _list) 
{ 
  string FilePath = "~/Upload/" + row.FileID; 
  string path = this.Server.MapPath(FilePath); 
  System.IO.FileInfo file = new System.IO.FileInfo(path); 
  FileStream fs = file.OpenRead(); 
  Attachment at = new Attachment(fs, row.FileName); ; 
  _attchmentlist.Add(at); 
} 

It works fine with images, but when I try to send zip file or mp3 file
it get me message "sending failed".
When I follow the error, I found the following execption
index was out of range
So, is there any limit on file size or type?
Posted
Updated 20-Nov-11 22:09pm
v2

1 solution

The issue can be due to the limit of httpRuntime default maxRequestLenght which if 5MB, but this is genarlly caused if you try to upload the files to server having size more than 5MB.
try the same after adding the below line to the web config. might that help
<httpRuntime maxRequestLength="1048576" executionTimeout="360"/>


or the issue can be cause by the iis. Read more about maxAllowedContentLength.
also check the link
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900