protected void sendImg_Click(object sender, EventArgs e) { string strMailContent = "Welcome new user"; string fromAddress = "[email protected]"; string toAddress = "[email protected]"; string contentId = "image1"; string path = Server.MapPath(@"img/LogoWeb.jpg"); // my logo is placed in images folder MailMessage mailMessage = new MailMessage(fromAddress, toAddress); mailMessage.Subject = "Welcome new User";
LinkedResource logo = new LinkedResource(path); logo.ContentId = "companylogo"; // done HTML formatting in the next line to display my logo AlternateView av1 = AlternateView.CreateAlternateViewFromString(" " + strMailContent, null, MediaTypeNames.Text.Html); av1.LinkedResources.Add(logo);
mailMessage.AlternateViews.Add(av1); // mailMessage.AlternateViews.Add(imageView); mailMessage.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); //use this if you are in the development server
smtp.Send(mailMessage); }
|