TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
raja n
1.6k
108
2.2k
Mail issue using smtp
Jan 23 2017 11:48 PM
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
Reply
Answers (
5
)
Testing Asp.Net Web API - which tool is best
how to handle multiple link button event in gridview