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.Subject = "Rental Agreement Form";
            message.From = new System.Net.Mail.MailAddress("user@msssoftware.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;
            Label3.Text = "Mail sent Successfully";

can anyone help me out to resolve this error.

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).


  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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.