how to Email send with image in body by using Gmail
just like this Pic.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
KalaiRank #8,005 · 230 reputationPosted Mar 10, 2014, 2:37 AM EDT
http://www.codeproject.com/Articles/16730/Embed-image-in-Email-ASP-NET-C
http://www.aspdotnet-suresh.com/2010/12/how-to-send-mail-with-images-using.html
Lakshmanan Sethu SankaranarayanRank #124 · 17.7K reputationPosted Mar 10, 2014, 2:58 AM EDT
Abhijit PatilRank #700 · 3.4K reputationPosted Mar 10, 2014, 3:12 AM EDT
appSettings> add key="SMTP" value="SMTP Address"/> //like mail.gmail.com add key="MailFrom" value="Mail From"/> add key="Port" value="Port Number"/> //usually 25 add key="MailUserName" value="user name of the mail from which the mail will be sent"/> add key="MailPwd" value="Password"/> add key="To" value="To whom you're sending the mail"/> add key="CC" value="If there's any cc to add"/> /appSettings>Now in the .NET class file, write the following code. (Note that here we are not concerned about validations.)
MailMessage msg = new MailMessage(); string To, Cc; string strMailContent = "You can include your text here"; To = ConfigurationManager.AppSettings["To"].ToString(); Cc = ConfigurationManager.AppSettings["CC"].ToString(); //checking that if there exist a Cc if (Cc != "" && Cc != String.Empty && Cc != null) { msg.CC.Add(Cc); } msg.To.Add(To); msg.From = new MailAddress(ConfigurationManager.AppSettings["MailUserName"].ToString()); msg.Subject = sub; string path = Server.MapPath(@"images/Logo.jpg"); // my logo is placed in images folder LinkedResource logo = new LinkedResource(path); logo.ContentId = "companylogo"; //now do the HTML formatting AlternateView av1 = AlternateView.CreateAlternateViewFromString( "" + " " + strMailContent, null, MediaTypeNames.Text.Html); //now add the AlternateView av1.LinkedResources.Add(logo); //now append it to the body of the mail msg.AlternateViews.Add(av1); msg.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = ConfigurationManager.AppSettings["SMTP"].ToString(); smtp.Port = Int32.Parse(ConfigurationManager.AppSettings["Port"]); //for gmail smtp.EnableSSL=true; smtp.Credentials = new System.Net.NetworkCredential( ConfigurationManager.AppSettings["MailUserName"].ToString(), ConfigurationManager.AppSettings["MailPwd"].ToString()); smtp.Send(msg);