Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8943817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:52:51+00:00 2026-06-15T11:52:51+00:00

I have a Question to send mails with html and attachment as an embedded

  • 0

I have a Question to send mails with html and attachment as an embedded image.
I don’t know how I can use the Picture from my images folder as Background for a div.

here my code:

SmtpMail oMail = new SmtpMail("TryIt");
            SmtpClient oSmtp = new SmtpClient();

            oMail.From = "test@emailarchitect.net";

            oMail.To = "<my email>";

            oMail.Subject = "test";

            SmtpServer oServer = new SmtpServer("<smtp server>");

            try
            {
               // Attachment header = oMail.AddAttachment("d:\\mail_header.jpg");
                Attachment header = oMail.AddAttachment("images/mail_header.jpg"); // this don't work
                Attachment oAttachment = oMail.AddAttachment("d:\\bg_content.jpg");
                Attachment Footer = oMail.AddAttachment("d:\\mail_footer.jpg");

                string contentID_header = "header";
                header.ContentID = contentID_header; 

                string contentID = "test001@host";
                oAttachment.ContentID = contentID;

                string contentID_footer = "footer";
                Footer.ContentID = contentID_footer; 

//how I can use a pic as background

                oMail.HtmlBody = "<html><body>"+
                                    "<div style='background-image:url(" + contentID_header + ");width: 800px;height: 50px'></div>" +
                                    "<div><img src=\"cid:" + contentID + "\"></div>" +
                                    "<div><img src=\"cid:" + contentID_footer + "\"></div>" +
                                    "</body></html>";

                oSmtp.SendMail(oServer, oMail); 

            }
            catch (Exception ep)
            {
                txtSimulate.Text = ep.Message; 
            } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:52:52+00:00Added an answer on June 15, 2026 at 11:52 am

    I use this code, it is working nice using LinkedResources with Alternateviews.
    Much better than hardcoding CIDS.

    Check it:

    System.Net.Mail.MailMessage Mensaje = new System.Net.Mail.MailMessage("mail@host.com",DireccionCorreo);
    
    System.Net.Mail.AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(Body, null, "text/html");
    
    
    System.Net.Mail.LinkedResource logo = new System.Net.Mail.LinkedResource("logoimage.jpg");
    logo.ContentId = "logoimage";
    htmlView.LinkedResources.Add(logo);
    
    System.Net.Mail.LinkedResource logoExchange = new System.Net.Mail.LinkedResource("logoexchange.png");
    logoExchange.ContentId = "logoexchange";
    htmlView.LinkedResources.Add(logoExchange);
    
    System.Net.Mail.LinkedResource tut1 = new System.Net.Mail.LinkedResource(Application.StartupPath + "/OutlookGuide/tut1.jpg");
    tut1 .ContentId = "tut1";
    htmlView.LinkedResources.Add(tut1 );
    
    System.Net.Mail.LinkedResource tut2 = new   System.Net.Mail.LinkedResource(Application.StartupPath + "/OutlookGuide/tut2.jpg");
    tut2.ContentId = "tut2";
    htmlView.LinkedResources.Add(tut2);
    
    
    Mensaje.AlternateViews.Add(htmlView);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question In SQL Server 2005, I have a table with images (data type: image).
I have two questions. I want to send SMSes from a web-site in PHP
I have question about parsing in Html helper : I have sth like: @foreach
I have question about XSLT1.0. The task is to write out in HTML all
I have question i.e how can i select a previous div CODE:- if($i >
I have question regarding the SQLAlchemy. How can I add into my mapped class
I have question regarding the use of function parameters. In the past I have
I need to send mails with java mail from a webserver over an exchange
I have question about sending emails from MVC3 application. I already read for exmple
I'm using post-receive-email hook from the Git distribution to send e-mails to certain users

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.