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.
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();