Hi,
I have written a email code in asp.net 4.0 which is working fine on Windows XP, Windows 7, Windows 8 operation system but when I am executing this on Windows Server 2008 operation system, It is showing an error. Please solve the problem...
Error is :
An attempt was made to access a socket in a way forbidden by its access permissions 202.137.236.12: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 202.137.236.12:25
Source Error:
|
My Code is :
using System;using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Net;
using System.Net.Mail;
public partial class Test_StudyDemo1_ScreeningNotificationTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SmtpClient m = new SmtpClient("smtp.rediffmailpro.com");
m.Port =587;
m.UseDefaultCredentials = true;
MailAddress To = new MailAddress("Here I have written recipient email id");
MailAddress From = new MailAddress("Here I have written Sender Mail Id which is on this smtp.rediffmailpro.com server");
MailMessage mm = new MailMessage(From, To);
mm.Subject = "Test Messge";
mm.IsBodyHtml = true;
mm.Body = "Test Mail";
m.Credentials = new System.Net.NetworkCredential("Here I have written Sender Mail Id which is on this smtp.rediffmailpro.com server", "Here I have written password of sender email id");
m.EnableSsl = true;
m.Send(mm);
}
}
Thanks in advance