This is the code I use to send my form via email:
protected void sendMail(string strFrom, string strBody)
{
//create the mail message
MailMessage mail = new MailMessage();
//set the addresses
mail.From = new MailAddress(strFrom);
mail.To.Add("myEmail@myDomain.com");
//set the content
mail.Subject = txtSubject.Text;
mail.Body = strBody;
mail.IsBodyHtml = false;
//send the message
SmtpClient smtp = new SmtpClient("noAuth.myDomain.com");
smtp.Send(mail);
}
And this is the error message I received:
Server Error in '/home' Application.
--------------------------------------------------------------------------------
Unable to read data from the transport connection: net_io_connectionclosed.
Description: An unhandled
exception occurred during the execution of the current web request.
Please review the stack trace for more information about the error and
where it originated in the code.
Exception Details: System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed.
Source Error:
Line 84: //send the message
Line 85: SmtpClient smtp = new SmtpClient("noAuth.myDomain.com");
Line 86: smtp.Send(mail);
Line 87: }
Line 88: }
Source File: e:\wwwroot\home\email.aspx.cs Line: 86

Error sending filled form via email
Will Pearson
Have you tried other Smtp servers, it doesn't seems to be an error in your code but just an error in the connection with the Smtp server.
vickey37139
Jean Pierre LaBonte
ljCharlie,
you can write:
smtp.Credentials = new NetworkCredential ("myusername", "mypassword");
this should go before the Send ().
Regards
--mc
Santiago C.
System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();
mail.From = "pj.vandesande@gmail.com";
mail.To = "somebody@msn.com";
mail.Subject = "Hello message!";
mail.Body = "Body of the message";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "USERNAME");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "PASSWORD");
System.Web.Mail.SmtpMail.SmtpServer = "mysmtp.server.com";
System.Web.Mail.SmtpMail.Send( mail );
Raschmann
You need the System.Net namespace.
--mc
mroctober
smtp.Credentials = new System.Net.NetworkCredential ("myusername", "mypassword");
KrisJ
Dim ObjSendMail
Dim iConf
Dim myField
Set ObjSendMail = Server.CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set myField = iConf.Fields
myField("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
myField("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "noAuth.myDomain.com"
myField("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
myField.Update
Set ObjSendMail.Configuration = iConf
ObjSendMail.Subject = request.Form("subject")
ObjSendMail.From = "webUser@yahoo.com"
ObjSendMail.HTMLBody = unescape(request.Form("body"))
do until emailRS.EOF
if len(emailRS("email")) > 5 then
'response.Write("sending mail")
ObjSendMail.To = emailRS("email")
ObjSendMail.Send
end if
emailRS.MoveNext
Loop
So how do I do the same thing in C#
jnelsonjr
The type or namespace name 'NetworkCredential' could not be found (are you missing a using directive or an assembly reference )
Roxanne163