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:
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); ; 

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?
Updated 20-Nov-11 22:09pm

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