-2
這在ASP.NET發送錯誤是電子郵件發送的代碼,但它在try
塊給出了錯誤:電子郵件使用C#
protected void Page_Load(object sender, EventArgs e)
{
EmailUtility email = new EmailUtility();
email.Email = new MailMessage();
string body = email.GetEmailTemplate(Server.MapPath("~/EmailTemplates"), "test.htm");
EmailMessageToken token = new EmailMessageToken();
token.TokenName = "$Name$";
token.TokenValue = "Ricky";
EmailMessageTokens tokens = new EmailMessageTokens();
tokens.Add(token);
//av.LinkedResources.Add(lr);
email.Email.Body = email.ReplaceTokens(body, tokens);
email.Email.To.Add(new MailAddress("[email protected]"));
email.Email.IsBodyHtml = true;
email.Email.From = new MailAddress("[email protected]");
email.Email.Subject = "Hello from bootcamp";
email.SMTP.Host = ConfigurationManager.AppSettings["SMTPServer"];
try
{
email.SMTP.Send(email.Email);
Response.Write("Email sent !");
}
catch (Exception ex)
{
Response.Write(ex.StackTrace);
}
}
的錯誤是:
at System.Net.Mail.IisPickupDirectory.GetPickupDirectory()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at _Default.Page_Load(Object sender, EventArgs e) in c:\Users\Sahil\Desktop\Csharp Email Code(2)\Test website\EmailTest.aspx.cs:line 38
發佈錯誤的全部內容(即'ex.ToString()')將提高無限回答這個問題的能力。 – Jamiec 2010-09-27 08:00:28
什麼是EmailUtility?看起來不是一個框架類。 – 2010-09-27 08:01:12
看起來您正在使用第三方庫。在我們提供幫助之前,我們至少需要知道您使用的是什麼。 – Carvellis 2010-09-27 08:01:41