You must Sign In to post a response.
  • Category: ASP.NET

    Error in Sending Mail

    Hi Everyone,Am creating an application, i want send a mail to user after he is registered.But now i got a error like this.i don't have idea for this error.So please friends if anyone know the meaning of this error.Please intimate me friends.

    This is the Error which i got:

    Server Error in '/ALUMNI PROCESS' Application.

    No connection could be made because the target machine actively refused it 108.163.250.251: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: No connection could be made because the target machine actively refused it 108.163.250.251:25

    Source Error:


    Line 42: smtpclient.UseDefaultCredentials = false;
    Line 43: smtpclient.Credentials = ocredential;
    Line 44: smtpclient.Send(message);
    Line 45: }
    Line 46: }

    Thanks with
    Paul.S
  • #762183
    Hi

    If you need some setting change in your gmail account for mail sent purpuse.

    then check your Credentials correct or not in your mail account .

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #762187
    hi

    you can go through below links

    http://www.codeproject.com/Questions/426966/System-Net-Sockets-SocketExcep

    http://www.codeproject.com/Questions/58761/No-connection-could-be-made-because-the-target-ma


    http://stackoverflow.com/questions/2972600/no-connection-could-be-made-because-the-target-machine-actively-refused-it

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #762191
    Hello Paul Raj,

    Refer the below code for sending email :

    using System.Net;
    using System.Net.Mail;

    public void MsgBox(String ex, Page pg, Object obj)
    {
    string s = "<SCRIPT language='javascript'>alert('" + ex.Replace("\r\n", "\\n").Replace("'", "") + "'); </SCRIPT>";
    Type cstype = obj.GetType();
    ClientScriptManager cs = pg.ClientScript;
    cs.RegisterClientScriptBlock(cstype, s, s.ToString());
    }

    MailMessage mailmesssage = new MailMessage();
    mailmesssage.From = new MailAddress("sender@gmail.com", "Company Name");
    mailmesssage.To.Add("receiver@gmail.com");
    mailmesssage.Subject = "Recently visited / enquiry user details";
    mailmesssage.Body = "Testing purpose";

    //G-mail settings
    try
    {
    SmtpClient smtpClient = new SmtpClient("smtp.gmail.com");
    smtpClient.Port = 587;
    smtpClient.Credentials = new NetworkCredential("sender@gmail.com", "gmail_password");
    smtpClient.EnableSsl = true;
    smtpClient.Send(mailmesssage);
    MsgBox("Thank you for contacting us." + Environment.NewLine + "We will get back you soon.", this.Page, this);
    }
    catch (Exception ex)
    {
    MsgBox("An error occured." + Environment.NewLine + "Error details: " + ex.Message + "", this.Page, this);
    }


    Hope this will help you.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"


Sign In to post your comments