2
Reply

Problem with sending mail

prit999

prit999

Mar 18 2004 2:58 PM
1.8k
Hi, I am trying to send email from my webpage in response to a button click. The emails seem to end up in the badmail folder. Please help me. Error displayed in badmail folder: ----------- Unable to deliver this message because the follow error was encountered: "This message is a delivery status notification that cannot be delivered.". The specific error code was 0xC00402C7. The message sender was <>. The message was intended for the following recipients. [email protected] ----------- The code on my webform is: ---------- public class mailtest : System.Web.UI.Page { protected System.Web.UI.WebControls.Button Button1; public static void SendEmail(string To, string From, string Subject, string Body, System.Web.Mail.MailFormat Format) { System.Web.Mail.MailMessage Mailer = new System.Web.Mail.MailMessage(); Mailer.From = From; Mailer.To = To; Mailer.Subject = Subject; Mailer.Body = Body; Mailer.BodyFormat = Format; System.Web.Mail.SmtpMail.SmtpServer = "localhost"; System.Web.Mail.SmtpMail.Send(Mailer); } private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.Button1.Click += new System.EventHandler(this.Button1_Click); this.Load += new System.EventHandler(this.Page_Load); } #endregion private void Button1_Click(object sender, System.EventArgs e) { SendEmail("[email protected]","[email protected]","Test","Test",System.Web.Mail.MailFormat.Text); } } --------------- Thanks in advance for your help.

Answers (2)