Hi
I am using smtp for sending mail. when i send mail for without attachment means mail sent successfully,but with attachment means not received in mail and no error came in server(file hosted) but local machine working good.
my code is
string mailFrom, mailPw;
mailFrom = ConfigurationManager.AppSettings["mailfrom"].ToString();
mailPw = ConfigurationManager.AppSettings["mailpw"].ToString();
MailMessage mm = new MailMessage();
mm.From = new MailAddress(mailFrom);
mm.To.Add(toaddress_txt.Text.Trim());
mm.Subject = subject_txt.Text;
mm.Body = emailcontent_txt.Text;
mm.IsBodyHtml = true;
if (attachment_FileUpload.HasFile)
{
string FileName = Path.GetFileName(attachment_FileUpload.PostedFile.FileName);
mm.Attachments.Add(new Attachment(attachment_FileUpload.PostedFile.InputStream, FileName));
}
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.UseDefaultCredentials = true;
smtp.Credentials = new System.Net.NetworkCredential(mailFrom, mailPw);
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.EnableSsl = true;
smtp.Send(mm);
smtp.Dispose();
Thnks in advance
Bryian TanPosted Jan 24, 2017, 12:02 AM
Bryian TanPosted Jan 25, 2017, 9:45 AM
Rajeesh MenothPosted Jan 24, 2017, 7:49 AM
raja nPosted Jan 24, 2017, 6:18 AM
Saber ShaikhPosted Jan 23, 2017, 11:55 PM