help with sending emails
-
can anybody plz help me find errors in this code. i am trying to send an email but i really cant. i cant figure out why.. :( protected void btnSubmit_Click(object sender, EventArgs e) { MailMessage message = new MailMessage(); message.To = txtTo.Text; message.From = txtFrom.Text; message.Subject = txtSubject.Text; message.Body = txtBody.Text; try { SmtpMail.SmtpServer= "localhost"; SmtpMail.Send(message); litStatus.Text = "Your email has been sent"; } catch (Exception ex) { litStatus.Text="Error sending email"; } } }:( kaaj
-
can anybody plz help me find errors in this code. i am trying to send an email but i really cant. i cant figure out why.. :( protected void btnSubmit_Click(object sender, EventArgs e) { MailMessage message = new MailMessage(); message.To = txtTo.Text; message.From = txtFrom.Text; message.Subject = txtSubject.Text; message.Body = txtBody.Text; try { SmtpMail.SmtpServer= "localhost"; SmtpMail.Send(message); litStatus.Text = "Your email has been sent"; } catch (Exception ex) { litStatus.Text="Error sending email"; } } }:( kaaj
SmtpMail may require a user name and password as well as a valid from recipient. Also, is your local IIS setup as SMTP?
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway -
can anybody plz help me find errors in this code. i am trying to send an email but i really cant. i cant figure out why.. :( protected void btnSubmit_Click(object sender, EventArgs e) { MailMessage message = new MailMessage(); message.To = txtTo.Text; message.From = txtFrom.Text; message.Subject = txtSubject.Text; message.Body = txtBody.Text; try { SmtpMail.SmtpServer= "localhost"; SmtpMail.Send(message); litStatus.Text = "Your email has been sent"; } catch (Exception ex) { litStatus.Text="Error sending email"; } } }:( kaaj
-
can anybody plz help me find errors in this code. i am trying to send an email but i really cant. i cant figure out why.. :( protected void btnSubmit_Click(object sender, EventArgs e) { MailMessage message = new MailMessage(); message.To = txtTo.Text; message.From = txtFrom.Text; message.Subject = txtSubject.Text; message.Body = txtBody.Text; try { SmtpMail.SmtpServer= "localhost"; SmtpMail.Send(message); litStatus.Text = "Your email has been sent"; } catch (Exception ex) { litStatus.Text="Error sending email"; } } }:( kaaj
i think these modifications will make it work protected void btnSubmit_Click(object sender, EventArgs e) { MailMessage message = new MailMessage(); message.To.Add(new MailAddress(txtTo.Text, "any user Name"); mMail.From = new MailAddress(txtFrom.Text, "any user Name"); message.Subject = txtSubject.Text; message.Body = txtBody.Text; try { SmtpClient sm = new SmtpClient(); sm.Send(message); litStatus.Text = "Your email has been sent"; } catch (Exception ex) { litStatus.Text="Error sending email"; } } } in web.config, configure smtp think this shud work
CST