Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Here i am facing problem during email send via rediffmail smtp client. Here email send properly using gmail and webmail(smtp.logix.in)

Following is my code.....

C#
MailMessage Message = new MailMessage();
Message.IsBodyHtml = true;
string to=txtCustEmail.Text;
string from = txtYourEmail.Text;
string password = txtPass.Text;


Message.To.Add(new MailAddress(to));
Message.From = (new MailAddress(from, "ADMIN"));
Message.Subject = txtMsgSub.Text;
Message.Body = txtMsgBody.Text;
Message.Attachments.Add(new Attachment("D:\\Excise2.xlsx"));


NetworkCredential NetworkCred = new NetworkCredential(from, password);

SmtpClient sc =new SmtpClient();
if (radioButton1.Checked==true)
{
   sc = new SmtpClient("smtp.gmail.com");
}
if (radioButton2.Checked==true)
{
     sc = new SmtpClient("smtp.logix.in");
}
if (radioButton3.Checked == true)
{
    sc = new SmtpClient("smtp.rediffmail.com");
}
sc.Port = 587;

//sc.Host=
sc.Credentials = NetworkCred;
sc.EnableSsl = true;

sc.Send(Message);
MessageBox.Show("Email send to " + Message.To);

Message.Dispose();


Email send Properly through gmail and logix but not for rediffmail.com even my rediffmail credential are correct.It shows following exception

SmtpException was handled...Failure sending mail.


Please help me........
Thanks
Posted
Comments
aarif moh shaikh 31-Dec-15 0:23am    
change sc.Port=25;
SujataJK 31-Dec-15 0:39am    
already changed still not working i gives following exception
InvalidOperationException ....The SMTP Host is not specified
Richard MacCutchan 31-Dec-15 4:14am    
Use your debugger to find out why the client is not being set. You could also add code to check that you have a valid client after all the if statements. Although that would mean rewriting that portion of code better.
SujataJK 31-Dec-15 0:41am    
thanks for your early reply
SujataJK 31-Dec-15 5:23am    
@Richard
I used debugger and also rewrite code then also same issue.
Also I used smtp.rediffmail.com in separate program still same issue.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900