如何用pdf发送邮件,图像作为附件 [英] how can sent mail with pdf, images as attachment

查看:484
本文介绍了如何用pdf发送邮件,图像作为附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我可以发送带附件的邮件。但收到0个字节。



我的代码如下:





I can sent mail with attachment. But received 0 bytes.

My code is given below.

if (FileUpload1.HasFile)
{
string FileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
Attachment attachment = new Attachment(FileUpload1.FileContent, FileName);
mm.Attachments.Add(mailAttach);
}





收到它的名字,但感觉为0字节。



我该如何解决呢。



请帮帮我..



在此先感谢,

Vineeth @



Received it's name but sensding as 0 bytes.

How can i solve it.

please help me..

Thanks in advance,
Vineeth@

推荐答案

由于上传的文件是临时文件,您可能会遇到这种情况 - 或者您需要做一些工作。请改用此方法: http://imar.spaanjaars.com/412/sending -attachments-from-a-fileupload-control [ ^ ]
As uploaded file is temporary one, you might encounter such situations - or you need to do some work. Use this approach instead: http://imar.spaanjaars.com/412/sending-attachments-directly-from-a-fileupload-control[^]


可以试试这个。

can u try this.
if (FileUpload1.HasFile)//Attaching document
                  {
                      string FileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
                      message.Attachments.Add(new Attachment(FileUpload1.PostedFile.InputStream, FileName));
                  }


这篇关于如何用pdf发送邮件,图像作为附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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