Send email programatically in from discountasp

Posted on 2011-04-24
Last Modified: 2012-05-11
This worked in my previous site host:

MailMessage mail = new MailMessage();

        mail.IsBodyHtml = true;

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

mail.Subject... etc
     //  SmtpClient smtp = new SmtpClient("", 8889); previous host, worked
     SmtpClient smtp = new SmtpClient("", 8889);
// current host(discountasp) does not work.

Error on Send(mail)

No connection could be made because the target machine actively refused it]

What should I change? Is 8889 the correct port for discountasp?
Question by:Dovberman
    LVL 4

    Accepted Solution

    Kindly confirm from your hosted providers that they have configured SMTP on their server and get the SMTP settings from them.
    If they have configured it locally  (which most service provider have) then you can use "localhost" as a SMTP server. Here will be an example for you.

    MailMessage mail = new MailMessage();

            mail.IsBodyHtml = true;

            //set the addresses
            mail.From = new MailAddress(strUserEmail);
            mail.To.Add(new MailAddress(""));
    System.Web.Mail.SmtpMail.SmtpServer = "localhost";

    LVL 4

    Expert Comment

    You can also check that either local SMTP is configured or not by using following command in command prompt on that machine.

    telnet localhost 25.

    Kindly also note that normally SMTP is configured on port 25. Check with your providers if they have configured it on another port.

    Have a look here. It may also help you.
    LVL 2

    Assisted Solution

    seems like in previous the smtp service was running on non-default port (8889) (or Nated at the end firewall) . You can either request the same or ask for new configuration.

    If you are sure that nothing is changed at the server end; so you can also check the firewall at the pc/server on which you are running the code. It may happen that communication is blocked on that machine on non standard ports.
    LVL 4

    Assisted Solution

    Hosts are really good about telling you what their setup is. They will normally have pre-scripted forms available in their cpanel. Who is your host? Have you given them a copy of that script? What do they say? Is there a specific port or server they want you to send through? Does the host require authentication?

    Probably not.


    Author Comment

    The host provided the information I needed:

                   SmtpClient smtp = new SmtpClient("", 25);
                    NetworkCredential Credentials = new NetworkCredential("", "mypassword");
                    smtp.Credentials = Credentials;

    Thanks for your help.

    Author Closing Comment

    Thank you.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
    I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now