Hi All,
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 72.14.225.72: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 72.14.225.72:25
Source Error:
Line 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
Stack Trace:
(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("sender@gmail.com", "John");
myMessage.To.Add(new MailAddress("receiver@gmail.com", "Smith"));
SmtpClient mySmtpClient = new SmtpClient();
mySmtpClient.Send(myMessage);
}
web.config page:
<system.net>
<mailSettings>
<smtp deliveryMethod=“Network” from=“John <sender@gmail.com>”>
<network host=“smtp.google.com” userName=“sender” password=“password”/>
</smtp>
</mailSettings>
</system.net>
</configuration>
Please help me in my quest to learn .NET, Thanks in advance.
Regards,
mikestar20