Sending mail using C#
<p>I have to send mail using C#. I follow each and every step properly, but I cannot send mail using the code below. Can anybody please help me to solve this issue? I know it's an old issue and I read all the related articles on that site about it. But I cannot solve my issue. So please help me to solve this problem. The error is: <code>Failure sending mail</code>. I use <code>System.Net.Mail</code> to do it.</p>

<pre><code>using System.Net.Mail;

string mailTo = emailTextBox.Text;
string messageFrom = "riad@abc.com";
string mailSubject = subjectTextBox.Text;
string messageBody = messageRichTextBox.Text;
string smtpAddress = "mail.abc.com";
int smtpPort = 25;
string accountName = "riad@abc.com";
string accountPassword = "123";

MailMessage message = new MailMessage(messageFrom, mailTo);                            
message.Subject = mailSubject;
message.SubjectEncoding = System.Text.Encoding.UTF8;
message.Body = messageBody;
message.BodyEncoding = System.Text.Encoding.UTF8;              
SmtpClient objSmtp = new SmtpClient(smtpAddress, smtpPort);
objSmtp.UseDefaultCredentials = false;
NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential(accountName, accountPassword);
objSmtp.Credentials = basicAuthenticationInfo;
objSmtp.Send(message);                                
MessageBox.Show("Mail send properly");
</code></pre>
