Using ASP.NET to Send Mail to Discountasp

Discussion in 'ASP.NET / ASP.NET Core' started by stockpicker, Apr 24, 2011.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I am not able to use the mail class to send mail to or from my discountasp mail account. I am using c#.

    This is what I am trying:

    MailMessage mail = new MailMessage();

    mail.IsBodyHtml = true;

    //set the addresses
    mail.From = new MailAddress(strUserEmail);
    mail.To.Add(new MailAddress("[email protected]"));

    //set the content
    mail.Subject = "Error Notice - StockPickerMax";
    mail.Body = strBody;

    //send the message
    if (strConnection.Contains("StockProSQL")) // Local server
    {
    // do not send mail;
    }
    else // Remote server
    {
    SmtpClient smtp = new SmtpClient("smtp.stockpickermax.com", 8889);

    smtp.Send(mail);
    }

    This is the error:

    No connection could be made because the target machine actively refused it 64.79.170.142:8889
    Description: An unhandled exception occurred during the execution of the current web request.

    Exception Details: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 64.79.170.142:8889

    Source Error:


    Line 182: SmtpClient smtp = new SmtpClient("smtp.stockpickermax.com", 8889);
    Line 183:
    Line 184: smtp.Send(mail);
    Line 185: }
    Line 186: conStockSelect.Close();

    I received the following from discountasp support:

    You will either have to use "localhost" which doesn't require authentication when sending, or you'll have to use your SMTP server (smtp.stockpickermax.com) using a valid email address (ie. [email protected]) with the password to the account.

    ------

    "localhost" does not work for me.

    I need toknow how to code the following:

    or you'll have to use your SMTP server (smtp.stockpickermax.com) using a valid email address (ie. [email protected]) with the password to the account.

    Thanks,
     
  2. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    When you use 'localhost' as your SMTP server, leave the username and password blank (i.e. don't set them).
     
  3. Unable to send mail - Solution

    The following code resolved this for me.

    SmtpClient smtp = new SmtpClient("smtp.stockpickermax.com", 25);
    NetworkCredential Credentials = new NetworkCredential("[email protected]", "mypassword");
    smtp.Credentials = Credentials;

    smtp.Send(mail);
     
  4. ...Awesome.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page