发布网站后发送附件和电子邮件时出错。 [英] Error while sending attachment with email after publishing the site.
问题描述
我想发送一个文本文件作为附件与电子邮件。当我在本地开发服务器上运行我的代码时,它运行正常,文件得到附加。但是当我在服务器上发布网站时,它没有选择附件和邮件也没有发送。这不是发送邮件的问题,bcoz我通过发送没有附件的邮件检查了它,邮件发送了。问题是在附加文件时。我已经写了文本文件附件的路径为
string filepath = @E:\ Pwavel \Attachfile \+ filename;
附件MyAttachment =新附件(文件路径);
objmsg.Attachments.Add(MyAttachment);
我还创建了Pwavel和服务器E盘中的Attachfile文件夹。
路径有问题吗?或任何许可问题?我无法理解问题是什么。请帮助我...
I want to send a text file as an attachment with email.When i run my code on local development server it runs properly and file gets attached.But when i publish the site on server,It doesnt pick the attachment and the mail is also not sent.Its not an issue of sending mails,bcoz i have checked it by sending mail without attachment,and the mail is sent.The problem is only while attaching file.i have written the path for text file attachment as
string filepath=@"E:\Pwavel\Attachfile\" + filename;
Attachment MyAttachment = new Attachment(filepath);
objmsg.Attachments.Add(MyAttachment);
I have also created "Pwavel" and "Attachfile" folders in E drive of server.
Is there a problem in path ? or any permission issue? i am not able to understand what the problem is..Please Help me...
推荐答案
你好pwavell
首先通过以下代码将文件保存到Web应用程序中
hello pwavell
first you saved the file into Webapplication through following Code
fileupload.SaveAs(FilePath+fileName)
然后附上文件
Then Attachment the file
你好pwavell
使用此代码
Hello pwavell
use This Code
System.Net.Mail.Attachment mailatt = new Attachment(File);
mail.Attachments.Add(mailatt);
因为
System.Web.Mail和System.Web.Mail互相冲突
快乐编码
Because
System.Web.Mail and System.Web.Mail Conflict Each Other
Happy Coding
这篇关于发布网站后发送附件和电子邮件时出错。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!