Hello Friend,
Firstly, you must PING the host and check if it is available.
Next you must do one thing, check if your internet connection is through a proxy, if so, remove it.
Try this :
protected static string SendEmail(string from,string password,string host,int port,string toAddress,string[] CCAdress,string subject, string body)
{
string result = "Message Sent Successfully..!!";
string senderID = from;
string senderPassword = password;
try
{
SmtpClient smtp = new SmtpClient
{
Host = host,
Port = port,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
Credentials = new System.Net.NetworkCredential(senderID, senderPassword),
Timeout = 30000,
};
MailMessage message = new MailMessage(senderID, toAddress, subject, body);
foreach (string email in CCAdress)
{
message.CC.Add(email);
}
message.Subject = subject;
smtp.Send(message);
}
catch (Exception ex)
{
Console.WriteLine(ex);
result = "Error sending email.!!!";
}
return result;
}
Just try this,.....
From the main method call the above code with correct parameters.....
I would like to thank OG(Original Griff)for this....(i read OG's article...great one).
One doubt:Using Proxy Server....(You wont be able to send an email)...Why?
Thanks