Как мы можем добавить встроенное изображение в качестве логотипа в Почте как я могу добавить логотип
Дорогие все
я хочу добавить логотип в свою почту когда я использую для добавления встроенного изображения это не входит
встроенный логотип прикрепляется как файл, но не входит в тело.
Что я уже пробовал:
private AlternateView getEmbeddedImage(String filePath) { LinkedResource res = new LinkedResource(filePath, "image / jpeg"); res.ContentId = Guid.NewGuid().ToString(); string rgt = @"<img src='cid:" + res.ContentId + @"'/>"; //res.TransferEncoding = TransferEncoding.Base64; string htmlBody = rgt; AlternateView alternateView = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html); alternateView.ContentType = new ContentType("text/html"); alternateView.LinkedResources.Add(res); return alternateView; } public int SendMailMultipleAttachments(string Subject, string Body, string AttachmentFiles, string CC = "", string BCC = "") { SqlConnection connEMail = new SqlConnection(); SqlCommand commEMail = new SqlCommand(); BCC="jugal.kishor@vkalra.com,rituraj.uniyal@vkalra.com"; try { //SmtpMail oMail = new SmtpMail("TryIt"); MailMessage mail = new MailMessage(); string otsmtp = null; string semail = null; string inpop = null; string usern = null; string userp = null; semail = ""; otsmtp = ""; inpop = ""; usern = ""; userp = ""; SqlDataReader nrs1; connection(); con.Open(); commEMail = new SqlCommand("select * from SendingEmailAccount where email='" + ddlsenderemailaccount.SelectedValue + "'", con); nrs1 = commEMail.ExecuteReader(); if (nrs1.HasRows) { while (nrs1.Read()) { otsmtp = nrs1["otsmtp"].ToString().Trim(); semail = nrs1["euser"].ToString().Trim(); inpop = nrs1["inpop"].ToString().Trim(); usern = nrs1["usern"].ToString().Trim(); userp = nrs1["pass"].ToString().Trim(); } } nrs1.Close(); mail.From = new MailAddress(semail); mail.To.Add("jugal.kishor@vkalra.com"); //mail.To.Add(semail); mail.Subject = Subject; mail.Bcc.Add(BCC); mail.IsBodyHtml = true; string sg = "<p>KNOWLEDGE MANAGEMENT TEAM |" + ddlcatagory.SelectedItem.ToString().ToUpper() + "</P>"; Body = Body + sg; AlternateView plainView = AlternateView.CreateAlternateViewFromString(Body, null, "text/html"); mail.AlternateViews.Add(plainView); //var inlineLogo = new LinkedResource(Server.MapPath("vkclogo.jpg")); //inlineLogo.ContentId = Guid.NewGuid().ToString(); //string sg = "<p>KNOWLEDGE MANAGEMENT TEAM |" + ddlcatagory.SelectedItem.ToString().ToUpper() + "</P>"; //string foottext = "<p>Print this mail only if absolutely necessary. Save Paper. Save Trees.<br/>Disclaimer<br/>VKC is not responsible for any kind of loss arising due to the information. You are receiving this news flash because you have subscribed to this service. To unsubscribe click here and send or click here to open unsubscribe webpage."; //string body = ""; //string img = string.Format(@"<img src=""cid:{0}"" />", inlineLogo.ContentId); //body = sg + img + foottext; //var view = AlternateView.CreateAlternateViewFromString(body, null, MediaTypeNames.Text.Html); //view.LinkedResources.Add(inlineLogo); //mail.AlternateViews.Add(view); // string foottext = "<p>Print this mail only if absolutely necessary. Save Paper. Save Trees.<br/>Disclaimer<br/>VKC is not responsible for any kind of loss arising due to the information. You are receiving this news flash because you have subscribed to this service. To unsubscribe click here and send or click here to open unsubscribe webpage."; string pt = Server.MapPath(@"vkclogo.jpg"); if (!string.IsNullOrEmpty(pt)) { mail.AlternateViews.Add(getEmbeddedImage(pt)); } //mail.AlternateViews.Add(Mail_Body()); //mail.Body = "<html>" & "<head>" & "<meta content=" & "en-us" & "http-equiv=" & "Content-Language">" & "<meta content=" & "text/html; charset=utf-8" & "http-equiv="Content-Type" & ">" & "<title>Fresh Newsletter</title>" & "<style type="text/css">" & "body {" & " margin:0;" & " padding:0;" & " background-color:#cccccc;" & " background:#cccccc;" & "}" & "</style>" & "</head>" & "" & "<body bgcolor="#cccccc" link="#86ac3d" vlink="#86ac3d">" & body & "</body>" & "</html>" int t = 0; System.Net.Mail.Attachment attachment = default(System.Net.Mail.Attachment); if ((AttachmentFiles != null)) { string[] rt = AttachmentFiles.Split(','); for (t = 0; t < rt.Length; t++) { if (File.Exists(rt[t])) { attachment = new System.Net.Mail.Attachment(rt[t]); mail.Attachments.Add(attachment); } } } SmtpClient smtps = new SmtpClient(otsmtp); smtps.DeliveryMethod = SmtpDeliveryMethod.Network; smtps.Port = 25; smtps.Credentials = new System.Net.NetworkCredential(semail, userp, "Vkalra.ddn"); // smtps.EnableSsl = True smtps.Send(mail); mail.Dispose(); smtps.Dispose(); return 1; } catch (Exception ex) { return 0; } finally { connEMail.Close(); } }