Hi!
I getting the following error when trying to send a file uploaded to my email address
<<
The remote name could not be resolved: 'smtp.gmail.com'>>
I am using the following code:
string toEmailAddress = "xx@gmail.com";
string gmailId = "abc@gmail.com";
string password = "";
string bodyMsg = "Hello its testing mail";
MailMessage mail = new MailMessage();
mail.To.Add(toEmailAddress);
mail.From = new MailAddress(gmailId);
mail.Subject = TextBoxEmailAdress.Text;
mail.Body = bodyMsg;
mail.IsBodyHtml = true;
if (FileUpload1.HasFile)
{
mail.Attachments.Add(new Attachment(FileUpload1.PostedFile.InputStream, FileUpload1.FileName));
}
SmtpClient smtp = new SmtpClient("smtp.gmail.com");
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential(gmailId, password);
smtp.Send(mail);
and this image represent the form that I have on how I want to perform that: