发送带有附件的电子邮件时出错 [英] error when send email with attachment

查看:100
本文介绍了发送带有附件的电子邮件时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从网站发送电子邮件.该电子邮件包含附件.
这些附件是存在于名为upload

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); ; 
  _attchmentlist.Add(at); 
} 


它可以很好地处理图像,但是当我尝试发送zip文件或mp3文件时
它会提示我发送失败".
当我遵循该错误时,我发现了以下执行
索引超出范围
因此,文件大小或类型是否有限制?


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?

推荐答案

问题可能是由于httpRuntime默认maxRequestLenght的限制(如果为5MB,则通常是这样)如果您尝试将文件上传到大小超过5MB的服务器.
在将以下行添加到Web配置后,请尝试相同的操作.可能有帮助
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"/>



或问题可能是由iis引起的.进一步了解maxAllowedContentLength.
还要检查



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


这篇关于发送带有附件的电子邮件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆