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.

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.

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.