mail send using C# code debugging.
- by riad
Dear all,
I have to send mail using C#.I follow each and every step properly but i cannot send mail using this below code.Can anybody pls help me to solve this issue??I know its an old issue and i read all the related articles on that's site about it.But cannot solved my issue.So pls help me to solve this code.The error is: Failur sending mail.I use System.Net.Mail to do it
using System.Net.Mail;
string mailTo = emailTextBox.Text;
string messageFrom = "[email protected]";
string mailSubject = subjectTextBox.Text;
string messageBody = messageRichTextBox.Text;
string smtpAddress = "mail.abc.com";
int smtpPort = 25;
string accountName = "[email protected]";
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");
Thanks in advance
Riad