0

i am sending mail in asp.net using c#. Below i have pasted the C# code for sending mail but when i submit the form i am getting the error as Mailbox Unavailable.

System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
            //message.To.Add("xxx@gmail.com");
            message.Subject = "Rental Agreement Form";
            message.From = new System.Net.Mail.MailAddress("user@msssoftware.com");
            message.To.Add("xxxx@gmail.com");
            //message.CC.Add("xxxx@gmail.com");
            message.IsBodyHtml = true;
            message.Body = result;
            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com", 25);
            smtp.Host = "localhost";
            smtp.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
            smtp.Send(message);
            Label3.Text = "Mail sent Successfully";

can anyone help me out to resolve this error.

Edited by Nick Evan: Added code-tags

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by __avd
0

Try out this code - http://www.daniweb.com/forums/thread75595.html

i am getting the error as Mailbox Unavailable.

You need to set Relay IP-Address. (Relay restrictions).

Steps:

  1. Open IIS applet from the control panel
  2. Go to0 Default SMTP Virtual Server
  3. Select tab Access + Click on Relay.
  4. Add IP of localhost 127.0.0.1

Read members rules at daniweb - http://www.daniweb.com/forums/faq.php?faq=daniweb_policies

For easy readability, always wrap programming code within posts in (code) (code blocks) and (icode) (inline code) tags.

Please do not resurrect old threads.

Edited by mike_2000_17: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.