First time Sending email from my application

Discussion in 'ASP.NET / ASP.NET Core' started by Ethan, May 24, 2006.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. When trying to send an email from application using the following


    > code>


    string to = [email protected];


    string from = "[email protected]";


    string subject = "Using the new SMTP client.";


    string body = @"Using this new feature, you can send an e-mail message


    from an application very easily."; MailMessage message = new


    MailMessage(from, to, subject, body);


    string server = "localhost";


    SmtpClient client = new SmtpClient(server);


    client.Credentials = CredentialCache.DefaultNetworkCredentials;


    client.Send(message);


    I get the following error:


    Mailbox unavailable. The server response was: 5.7.1 Unable to relay for [email protected]


    Line 126: client.Credentials = CredentialCache.DefaultNetworkCredentials;


    Line 127:


    Line 128: client.Send(message);





    Can someonehelp me with this?
     
  2. Are you trying to send this from a DASP server?


    You shouldn't have to set the credentials.



    Joel Thoms
    DiscountASP.NET
    http://www.DiscountASP.NET
     
  3. Oh,


    The problem was I was running the application from my local machine. When I uploaded the application to discount asp the email worked fine.[​IMG]
     
  4. No. I tried it both with and without credentials. I copied the code from microsofts web site. This is the first time I am working thru this process so I am not tied to any solution. I just want to move past sending email from .net 2.0





    I appreciate the help.
     
  5. hehe...no wonder why....localhost is a 'REAL LOCAL', eh?[​IMG]

    J. L.
    Technical Support/IT Admin/MIS Developer
    Maxtop Enterprises Inc.
    http://www.maxtop.ca</CODE>
     
  6. When sending from your local network, you might have to use your ISP's SMTP server.



    Joel Thoms
    DiscountASP.NET
    http://www.DiscountASP.NET
     
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