如何使用处理程序发送邮件?

时间:2011-04-12 10:57:24

标签: email handler

我想发送邮件,所以我在handler.ashx中写了一个方法,但是我得到了错误

“SendUsing”配置值无效。这是什么意思请帮助我

public bool Sendmail()     {         bool strResult = false;         尝试         {

        email.Subject = " Registration";

        email.To = "ravivarma_07d@yahoo.com";
        email.From = "giribhushan.svg@gmail.com";
        email.Cc = "ravivarma_07d@yahoo.com";
        email.Bcc = "ravivarma_07d@yahoo.com";
        email.BodyFormat = MailFormat.Html;

        email.Body = "<html>" +
                       "<body>" +
                      "<b>Hi ravi</b>"+
                       "</body>" +
                       "</html>";
        email.Priority = MailPriority.Normal;


       SmtpMail.Send(email);
        strResult = true;
    }
    catch (Exception ex)
    {
        //FTEHelper.SendEmail("ticketupload@whohastwo.com", "Ticket Upload Batch Error",
        //   ex.ToString());


        strResult = false;

    }


    return strResult;





}

1 个答案:

答案 0 :(得分:1)

您应该指定一个SMTP服务器。

SmtpMail.SmtpServer = "yourservername";

此外,您应该考虑使用System.Net.Mail命名空间而不是System.Web.Mail。 (当然,如果你没有被迫使用.NET 1。)