SmtpClient SmtpServer = new SmtpClient(); SmtpServer.Credentials = new System.Net.NetworkCredential("info9@gmail.com", "********"); SmtpServer.Port = 587; SmtpServer.Host = "smtp.gmail.com"; SmtpServer.EnableSsl = true; mail = new MailMessage(); String[] addr = TextBox1.Text.Split(','); try { mail.From = new MailAddress("info9@gmail.com", "So and So", System.Text.Encoding.UTF8); Byte i; for( i = 0;i< addr.Length; i++) mail.To.Add(addr[i]); mail.Subject = TextBox3.Text; mail.Body = TextBox4.Text; if(ListBox1.Items.Count != 0) { for(i = 0;i<ListBox1.Items.Count;i++) mail.Attachments.Add(new Attachment(ListBox1.Items[i].ToString())); } LinkedResource logo = new LinkedResource(path); logo.ContentId = "Logo"; string htmlview; htmlview = "<html><body><table border=2><tr width=100%><td><img src=cid:Logo alt=companyname /></td><td>MY COMPANY DESCRIPTION</td></tr></table><hr/></body></html>"; AlternateView alternateView1 = AlternateView.CreateAlternateViewFromString(htmlview + TextBox4.Text, null, MediaTypeNames.Text.Html); alternateView1.LinkedResources.Add(logo); mail.AlternateViews.Add(alternateView1); mail.IsBodyHtml = true; mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess; mail.ReplyTo = new MailAddress(TextBox1.Text); SmtpServer.Send(mail); } catch (Exception ex){ MessageBox.Show(ex.ToString()); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)