from past few weeks i'm unable to overcome from this error in ASP.Net when sending email(I am a beginner in .NET). Would be great if i could get a solution here. Thanks.
Error Page-(Internet Explorer)
Server Error in '/Site' Application.
An attempt was made to access a socket in a way forbidden by its access permissions 22.214.171.124:25
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.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 126.96.36.199:25
Line 26: SmtpClient mySmtpClient = new SmtpClient();
Line 27: mySmtpClient.Send(myMessage);
Line 28: }
Line 29: }
Source File: c:\BegASPNET\Site\Demos\Email.aspx.cs Line: 27
(Full of Codes, not needed i guess, ??)
some part of "aspx.cs" page:
protected void Page_Load(object sender, EventArgs e)
MailMessage myMessage = new MailMessage();
myMessage.Subject = "Test Message";
myMessage.Body = "Hello world, from planet wrox";
myMessage.From = new MailAddress("email@example.com", "John");
myMessage.To.Add(new MailAddress("firstname.lastname@example.org", "Smith"));
SmtpClient mySmtpClient = new SmtpClient();
<smtp deliveryMethod="Network" from="John <email@example.com>">
<network host="smtp.google.com" userName="sender" password="password"/>
Please help me in my quest to learn .NET, Thanks in advance.