try { MailMessage Msg = new MailMessage(); // Sender e-mail address. Msg.From = new MailAddress(txtUsername.Text); // Recipient e-mail address. Msg.To.Add(txtTo.Text); Msg.Subject = txtSubject.Text; // File Upload path //String FileName = fileUpload1.PostedFile.FileName; string path = Server.MapPath("~/images/byohbaraat logo.png"); string mailbody = txtBody.Text + "<br /><img src=cid:companylogo>"; LinkedResource myimage = new LinkedResource(path); // Create HTML view AlternateView htmlMail = AlternateView.CreateAlternateViewFromString(mailbody, null, "text/html"); // Set ContentId property. Value of ContentId property must be the same as // the src attribute of image tag in email body. myimage.ContentId = "companylogo"; htmlMail.LinkedResources.Add(myimage); Msg.AlternateViews.Add(htmlMail); // your remote SMTP server IP. SmtpClient smtp = new SmtpClient(); smtp.Host = "mail.byohbaraat.com"; smtp.Port = 587; smtp.Credentials = new System.Net.NetworkCredential(txtUsername.Text, txtpwd.Text); smtp.EnableSsl = false; smtp.Send(Msg); Msg = null; Response.Write("Mail Sent Succesfully"); } catch (Exception ex) { Console.WriteLine("{0} Exception caught.", ex); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)