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 7049229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:59:16+00:00 2026-05-28T02:59:16+00:00

I’m sending an image through web form the image is displayed well into gmail

  • 0

I’m sending an image through web form the image is displayed well into gmail ,yahoo etc.
But i’m not able to view that image when I send it on Outlook
what would be wrong please help.

Code:

//Variable mg have a html code with  'cid:uniqueId1’ calls image from function SendMail12


void birthday()
        {
            Coonection con = new Coonection();
            sql = "select es.PORTNO,es.SERVERNAME,es.EMAILID,es.PASSWORD,e.efrom,e.SerNo,e.eto,e.ecc,e.emessage,e.eflag,e.EmpID,e.FIRSTNAME,e.LASTNAME,e.DeptName,e.FromDate,e.Todate,e.Reason from EMAILSETTING es,EmailSender e";


            SqlDataAdapter da = new SqlDataAdapter(sql, con.GetConnection());
            DataSet ds = new DataSet();
            da.Fill(ds);

            string sub = "Message";
            int portnum, n,sn;
            string servername1, passwo, account, t, ecc, mg, flage,mg2;
            sql = "select count(srno)from EmailSender";
            SqlCommand cmd = new SqlCommand(sql, con.GetConnection());
            // dr = cmd.ExecuteReader();
            n = Convert.ToInt32(cmd.ExecuteScalar());
            //while (i)
            //{
            for (int i = 0; i < n; i++)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {

                    portnum = Convert.ToInt32(ds.Tables[0].Rows[0]["PORTNO"].ToString());
                    servername1 = ds.Tables[0].Rows[0]["SERVERNAME"].ToString();      //Table(0).Rows(0)("SmtpServerName").ToString();
                    account = ds.Tables[0].Rows[0]["EMAILID"].ToString();
                    passwo = ds.Tables[0].Rows[0]["PASSWORD"].ToString();
                    t = ds.Tables[0].Rows[i]["eto"].ToString();
                    ecc = ds.Tables[0].Rows[i]["ecc"].ToString();
                    mg2 = ds.Tables[0].Rows[i]["emessage"].ToString();
                    flage = ds.Tables[0].Rows[i]["eflag"].ToString();
                    sn = Convert.ToInt32(ds.Tables[0].Rows[i]["SerNo"].ToString());

                    if (flage == "N" && mg2 == "Wish You a Very Happy Returns of the Day.<P> From - Daccess Security Systems Pvt ")
                    {
                        mg = " <html> " +
                            "<body background= 'meet.jpg'>" +
                           "<head>  " +
                           "<title>Untitled Document</title>  " +
                           "<meta content='text/plain; charset=us-ascii' http-equiv='Content-Type' />" +
                           "<style type='text/css'>  " +
                           ".style1 {  " +
                               "font-family: Arial, Helvetica, sans-serif;  " +
                               "font-weight: bold;  " +
                               "font-size: 18px;  " +
                               "color: #3333CC;  " +
                           "}  " +
                           ".style3 {  " +
                               "font-family: 'Times New Roman', Times, serif;  " +
                               "color: #003399;  " +
                           "}    " +
                           ".style4 {  " +
                               "font-family: Arial, Helvetica, sans-serif;  " +
                               "font-weight: bold;  " +
                               "font-size: 12px;  " +
                           "}  " +
                           ".style11 {  " +
                               "color: #1A588D;  " +
                               "font-family: 'Times New Roman', Times, serif;  " +
                               "font-weight: bold;  " +
                           "}  " +
                           ".style15 {  " +
                               "color: #1A588D;  " +
                               "font-weight: bold;  " +
                           "}  " +
                           ".style18 {color: #FFFFFF; font-weight: bold; }  " +
                           "body {  " +
                               "margin-top: 1px;  " +
                               "margin-left: 1px;  " +
                               "margin-right: 1px;  " +
                               "margin-bottom: 1px;  " +

                           "}  " +
                           "</style>  " +
                           "<link href='Untitled-1.htm' id='1' title='view'>  " +
                           "<script language='JavaScript' type='text/JavaScript'>  " +
                           "function MM_reloadPage(init) {   " +
                             "if (init==true) with (navigator) {if ((appName=='Netscape')&&(parseInt(appVersion)==4)) {  " +
                               "document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}  " +
                             "else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();  " +
                           "}  " +
                           "MM_reloadPage(true);  " +
                           "</script>  " +
                           "<style type='text/css'>  " +
                           "a:link {  " +
                               "text-decoration: none;  " +
                           "}  " +
                           "a:visited {  " +
                               "text-decoration: none;  " +
                           "}  " +
                           "a:hover {  " +
                               "text-decoration: none;  " +
                           "}  " +
                           "a:active {  " +
                               "text-decoration: none;  " +
                           "}  " +
                           ".style20 {font-size: 12px}  " +
                           "</style></head>  " +
                           "<body>  " +
                           "<p class='style1'><img src='cid:uniqueId' width='145' height='111'></p>  " +
                           "<table border= 1 align ='left'>" +
                           "<tr>" + "<td>Employee ID :" + "</td>" +
                           "<td>" + ds.Tables[0].Rows[i]["EmpID"].ToString() + "</td>" +
                           "</tr>" +
                           "<tr>" + "<td>Employee Name :" + "</td>" +
                           "<td>" + ds.Tables[0].Rows[i]["FIRSTNAME"].ToString() + " " + ds.Tables[0].Rows[i]["LASTNAME"].ToString() + "</td>" +
                           "</tr>" +
                           "<tr>" + "<td>Department :" + "</td>" +
                           "<td>" + ds.Tables[0].Rows[i]["DeptName"].ToString() + "</td>" +
                           "</tr>" +
                           "<tr>" + "<td>Message :" + "</td>" +
                           "<td>" + ds.Tables[0].Rows[i]["emessage"].ToString() + "</td>" +
                           "</tr>" +
                           "<tr>"+
                           "<td>"+
                           "<pre align='left' class='style3'><strong><img src='cid:uniqueId1' width='286' height='177'></strong></pre>  " +
                           "<pre align='left' class='style4'> <a name='t'></a> Please do not reply to this email.</pre>" +
                           "<p align='left' class='style3'>&nbsp;</p>  " +
                           "</td>"+"</tr>"+"</table>"+
                           "</body>  " +
                           "</html>  ";

                        if (flage == "N" && mg2 == "Wish You a Very Happy Returns of the Day.<P> From - Daccess Security Systems Pvt ")
                        {
                            SendMail12(account, passwo, t, sub, mg, ecc, servername1, portnum);
                            sql = "Update EmailSender set eflag ='Y' where SerNo = '" + sn.ToString() + "'";
                            SqlCommand cmd4 = new SqlCommand(sql, con.GetConnection());
                            cmd4.ExecuteNonQuery();
                        }
                    }
                }
                else
                {

                    servername1 = "";
                    portnum = 0;
                    account = "";
                    passwo = "";
                    MessageBox.Show("Email Setting Is Not Stored");
                }
            }
        }

// Send mail function
public static bool SendMail12(string gMailAccount, string password, string to, string subject, string message, string cc, string server, int port)
      {
          try
          {


              NetworkCredential loginInfo = new NetworkCredential(gMailAccount, password);
              MailMessage msg = new MailMessage();
              msg.From = new MailAddress(gMailAccount);
              msg.To.Add(new MailAddress(to));

              string[] s;
              s = cc.Split(';');

              for (int i = 0; i < s.Length; i++)
              {
                  msg.CC.Add(new MailAddress(s[i].ToString()));
              }

              msg.Subject = subject;
              msg.Body = message;
              msg.IsBodyHtml = true;

              SmtpClient client = new SmtpClient();
              client.Host = server;
              client.Port = port;
              client.Timeout = 100000;
              client.EnableSsl = true;
              client.UseDefaultCredentials = true;
              client.Credentials = loginInfo;
              string palinBody = "Plain text content, viewable by those clients that don't support html";
              AlternateView plainView = AlternateView.CreateAlternateViewFromString(palinBody, null, "text/plain");
              string htmlBody = message;
              AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlBody, null, "text/html");
              //create the AlternateView for embedded image 
              AlternateView imageView = new AlternateView("D:\\Aniket Work\\New Folder Update\\EmailSender\\EmailSender\\images\\Daccess-logo.gif", MediaTypeNames.Image.Gif);
              imageView.ContentId = "uniqueId";
              imageView.TransferEncoding = TransferEncoding.Base64;

              AlternateView imageView1 = new AlternateView("D:\\Aniket Work\\New Folder Update\\EmailSender\\EmailSender\\images\\birthday1images.jpg", MediaTypeNames.Image.Jpeg);
              imageView1.ContentId = "uniqueId1";
              imageView1.TransferEncoding = TransferEncoding.Base64;
              //add the views 
              msg.AlternateViews.Add(plainView);
              msg.AlternateViews.Add(htmlView);
              msg.AlternateViews.Add(imageView);
              msg.AlternateViews.Add(imageView1);

              client.Send(msg);

              return true;
          }
          catch (Exception e)
          {
              return false;
          }
      }

enter image description here

  • 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-05-28T02:59:16+00:00Added an answer on May 28, 2026 at 2:59 am

    You should be giving absolute paths to your resources

    e.g.

    in above code, your body background should be something like

    <body background= 'http://yourdomain.com/meet.jpg'>
    

    same thing applies to your image tag or you can have inline content disposition

    EDIT

    Do you see something like this when you view the mail?

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but

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.