【发布时间】:2014-02-22 03:11:42
【问题描述】:
我正在创建一个 Web 应用程序,它允许我的用户编辑像 gridview 这样的 Excel。
我合并了两个按钮,可以发送带有附件的 excel 文件的电子邮件,还有一个按钮可以显示正在发送的 excel 文件。
两者的问题在于,在请求仅查看文件时,它在本地显示良好,但当推送到我的网络服务器时,它根本不起作用。
使用另一个按钮将文件作为电子邮件的附件发送,它不会附加,但会发送电子邮件。
这是发送电子邮件的代码:
try
{
const string attachment = "summary.xlsx";
var mail = new MailMessage();
mail.To.Add("Tester@test.com");
mail.From = new MailAddress("Tester@test.com");
mail.Subject = "SummarySpreadsheet " + DateTime.Now.ToString("MM-dd-yyyy");
mail.Body = "Hello Everyone," + "\n" + "\n" +
"Attached is the Spreadsheet for your review." + "\n" + "\n" +
"Thank you!" + "\n" + "\n";
mail.Attachments.Add(new Attachment(Server.MapPath("//testserver/apps/testApp/Daily/summary.xlsx")));
var smtpClient = new SmtpClient("test.test.com"); //this is fake
smtpClient.Send(mail);
Response.Write("Email Sent Successfully!");
}
catch (Exception ex)
{
Response.Write("Could not send the email - error" + ex.Message);
}
}
这是我用来查看电子表格的代码:
System.Diagnostics.Process.Start(@"\\testserver\apps\testApp\Daily\summary.xlsx");
我进行了研究,发现了很多发送带有附件的电子邮件的方法,它们在本地工作,但是当推送到我的服务器时,没有任何作用。我已经复制了 dll 并确保一切都是一致的,但仍然没有变化。
在这方面的任何帮助都会很棒。
谢谢
【问题讨论】: