PDA

View Full Version : Sending email from a form


marlatim
01-11-2004, 06:55 AM
I am trying to send email from a .net page. Here is the essential code for instatiating the mailmessage object and assigning it properties.
MailMessage mailmessage = new MailMessage();

mailmessage.To = "mailto:tim_eproject@hotmail.com";
mailmessage.From = txtName.Text;
mailmessage.Subject = "New entry in the Guest book";
mailmessage.BodyFormat = MailFormat.Text;
mailmessage.Body = tboxcomments.Text; ;

SmtpMail.Send(mailmessage);

When I submit the form I get the following error message
The "SendUsing" configuration value is invalid.
with the line SmtpMail.Send(mailmessage); highlighted. Anybody know what this error means? Do I need to configure something in order to send email?
Thanks,</font id="Arial">
Tim

steurm
01-11-2004, 11:46 AM
Yep,

You need to set the value for the smtp server, which is "localhost".

[quote]mailmessage.To="mailto:tim_eproject@hotmail.com";
mailmessage.From=txtName.Text;
mailmessage.Subject="NewentryintheGuestbook";
mailmessage.BodyFormat=MailFormat.Text;
mailmessage.Body=tboxcomments.Text;;

SmtpMail.SmtpServer="localhost";</fontid="blue">
SmtpMail.Send(mailmessage);</CODE>

Success

--
Steurm
www.steurm.net/steurm

marlatim
01-12-2004, 01:48 AM
Thanks!