Forum Moderators: open
Here is the code:
protected void Button1_Click(object sender, EventArgs e)
{
MailMessage message = new MailMessage(TextBox2.Text,"#*$!@gmail.com");
message.Subject = "Subject";
message.Body = TextBox3.Text;
SmtpClient client = new SmtpClient("rs.mt.net.mk");
client.Send(message);
}
But since I am writing this I am going to say there are a limited number of exceptions.
I am going to guess SmtpException is being thrown. The reasons for this usually are the following.
The connection to the SMTP server failed.
-or-
Authentication failed.
-or-
The operation timed out.
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 25: //Send the message.
Line 26: SmtpClient client = new SmtpClient("rs.mt.net.mk");
Line 27: client.Send(message);
Line 28: // Add credentials if the SMTP server requires them.
Line 29: }
i really don't have a clue why it would execute just fine when i do "view in browser" but it doesnt when i upload it and try to start it from the server.
Try replacing "rs.mt.net.mk" with "127.0.0.1" and see if this works. This will send it though the local SMTP server on the server if there is one.