Hi,
I am having an error while passing a direct path to mail attachment.
Please check and update me soon. Dead line till today.
-
-
- public void sendmail_to_user()
- {
- string to = txtemail.Text;
- string from = "[email protected]";
- string[] Multiple = to.Split(',');
- MailMessage message = new MailMessage();
- message.From = new MailAddress(from);
- foreach (string multiple_email in Multiple)
- {
- message.To.Add(new MailAddress(multiple_email));
- }
-
-
-
- message.Attachments.Add(new Attachment("file/CrystalReportViewer1.pdf"));
-
-
-
-
-
- string mailbody = "Message Body";
- message.Subject = "Subject";
- message.Body = mailbody;
- message.BodyEncoding = Encoding.UTF8;
- message.IsBodyHtml = true;
- SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
- System.Net.NetworkCredential basicCredential1 = new
- System.Net.NetworkCredential("[email protected]", "Password");
- client.EnableSsl = true;
- client.UseDefaultCredentials = false;
- client.Credentials = basicCredential1;
- try
- {
- client.Send(message);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }