I am having an issue in my project trying to developing a mail webservice but getting an error transport failed to connect to server.
Below is the code...
protected void btnsubmit_Click(object sender, EventArgs e)
{
MailMessage mail = new MailMessage();
mail.From = "ruchi.dubey18@gmail.com";
mail.To = txtTo.Text.Trim();
mail.Subject = txtSubject.Text.Trim();
mail.Body = txtBody.Text.Trim();
SmtpMail.SmtpServer = "smtp.gmail.com";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", "2");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "ruchi.dubey18@gmail.com");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "jaishreek");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "2");
SmtpMail.Send(mail);
}
please help its urgent...