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 TanRank #396 · 6.3K reputationPosted Jan 23, 2017, 7:02 PM EST
Saber ShaikhRank #1,686 · 905 reputationPosted Jan 23, 2017, 6:55 PM EST
Rajeesh MenothRank #118 · 18.4K reputationPosted Jan 24, 2017, 2:49 AM EST
Bryian TanRank #396 · 6.3K reputationPosted Jan 25, 2017, 4:45 AM EST
raja n101 reputationPosted Jan 24, 2017, 1:18 AM EST