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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:44:20+00:00 2026-05-16T18:44:20+00:00

i have a strange problem with sending HTML mail in c#. Basically i am

  • 0

i have a strange problem with sending HTML mail in c#.

Basically i am trying to email myself the weather every morning and I begin by downloading the weather in HTML markup from an ftp site.

After obtaining the source file i then read it into a string and create a mailMessage using the following code.

string body = File.ReadAllText(@"C:\Weather.htm");

MailMessage mailMessage = new MailMessage();
SmtpClient mailClient = new SmtpClient("smtp.gmail.com");

mailClient.Credentials = new NetworkCredential(username, password);
mailClient.Port = 587;
mailClient.EnableSsl = true;
mailMessage.From = new MailAddress(emailFrom);
mailMessage.IsBodyHtml = true;    
mailMessage.To.Add(emailTo);
mailMessage.Subject = "Test Email";
mailMessage.SubjectEncoding = System.Text.Encoding.Unicode;
mailMessage.Body = body;
mailMessage.BodyEncoding = System.Text.Encoding.Unicode;
mailClient.Send(mailMessage);

The problem is that whilst the email arrives in HTML format, all of the DIV / CSS are not respected and it looks weird. I have tried to email to a different email address & client and it looks the same as well as trying different encodings.

So somewhere along the line something is going wrong.

Does anyone know how to fix this and get a properly formatted email?

Good Image

alt text

BadImage

alt text

source markup

<html xmlns="http://www.w3.org/1999/xhtml"><head xmlns="">
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Sydney Forecast</title>
        <link rel="stylesheet" type="text/css" href="http://www.bom.gov.au/watl/standard/common.css">
        <link rel="stylesheet" type="text/css" href="http://www.bom.gov.au/weather-services/styles/text-gfe.css">
    </head>
    <body>
        <div class="product">
            <p xmlns="" class="p-id">IDN10064</p>
            <p xmlns="" class="source">Australian Government Bureau of Meteorology<br/>New South Wales
            <h2 xmlns="">Updated Sydney Forecast</h2>
            <p xmlns="" class="date">Issued at 8:11 am&nbsp;EST on Thursday 9 September 2010<br>for the period until midnight EST&nbsp;Wednesday 15 September 2010.</p>
            <h3 xmlns="" class="warning">Warning Summary at issue time</h3>
            <p xmlns="">Nil.</p>
            <p xmlns="" class="p-id">Details of warnings are available on the Bureau's website www.bom.gov.au, by telephone 1300-659-218* or through some TV and radio broadcasts.</p>
            <h3 xmlns="" class="day">Forecast for the rest of Thursday</h3>
            <p xmlns="" class="sl">Cloud increasing. Areas of rain this afternoon and evening. Winds northerly averaging up to 20 km/h.</p>
            <div xmlns="" class="grid">
                <div class="line space-b">
                    <div class="name">City Centre</div>
                    <div class="wx">A little rain later.</div>
                    <div class="max_l">Max</div>
                    <div class="max_v">20</div>
                </div>
                <div class="line">
                    <div class="rain_l">Chance of any rainfall:</div>
                    <div class="rain_prob_v">30%</div>
                    <div class="rain_l">Chance of no rainfall:</div>
                    <div class="rain_prob_v">70%</div>
                    <div class="rain_l">Rainfall:</div>
                    <div class="rain_v">0 to 1 mm</div>
                </div>
                <div class="line space-b">
                    <div class="name">Penrith</div>
                    <div class="wx">Late rain.</div>
                    <div class="max_l">Max</div>
                    <div class="max_v">20</div>
                </div>
                <div class="line">
                    <div class="rain_l">Chance of any rainfall:</div>
                    <div class="rain_prob_v">30%</div>
                    <div class="rain_l">Chance of no rainfall:</div>
                    <div class="rain_prob_v">70%</div>
                    <div class="rain_l">Rainfall:</div>
                    <div class="rain_v">0 to 1 mm</div>
                </div>
                <div class="line">
                    <div>
                        <h4>Around Sydney</h4>
                    </div>
                </div>
                <div class="line">
                    <div class="name">Liverpool</div>
                    <div class="max_l">Max</div>
                    <div class="max_v">20</div>
                    <div class="name">Parramatta</div>
                    <div class="max_l">Max</div>
                    <div class="max_v">20</div>
                </div>
                <div class="line">
                    <div class="name">Terrey Hills</div>
                    <div class="max_l">Max</div>
                    <div class="max_v">19</div>
                    <div class="name">Campbelltown</div>
                    <div class="max_l">Max</div>
                    <div class="max_v">19</div>
                </div>
                <div class="line">
                    <div class="name">Richmond</div>
                    <div class="max_l">Max</div>
                    <div class="max_v">20</div>
                    <div class="name">Bondi</div>
                    <div class="max_l">Max</div>
                    <div class="max_v">19</div>
                </div>
            </div>
            <p xmlns="" class="sl">Fire Danger: Low to Moderate [0-11]</p>
            <p xmlns="" class="sl">UV Alert from 9:10 am to 2:40 pm, UV Index predicted to reach 6 [High]</p>
            <h3 xmlns="" class="day">Forecast for Friday</h3>
            <p xmlns="" class="sl">Partly cloudy. Winds west to northwesterly averaging up to 25 km/h tending westerly up to 40 km/h around midday.</p>
            <div xmlns="" class="grid">
                <div class="line space-b">
                    <div class="name">City Centre</div>
                    <div class="wx">Becoming windy.</div>
                    <div class="min_l">Min</div>
                    <div class="min_v">13</div>
                    <div class="max_l">Max</div>
                    <div class="max_v">22</div>
                </div>
                <div class="line space-b">
                    <div class="name">Penrith</div>
                    <div class="wx">Partly cloudy. Becoming windy.</div>
                    <div class="min_l">Min</div>
                    <div class="min_v">11</div>
                    <div class="max_l">Max</div>
                    <div class="max_v">23</div>
                </div>
            </div>
            <h3 xmlns="" class="day">Forecast for Saturday</h3>
            <p xmlns="" class="sl">Sunny. Winds west to southwesterly averaging up to 25 km/h tending mainly southeast to southwesterly up to 20 km/h around midday.</p>
            <div xmlns="" class="grid">
                <div class="line space-b">
                    <div class="name">City Centre</div>
                    <div class="wx">Sunny.</div>
                    <div class="min_l">Min</div>
                    <div class="min_v">12</div>
                    <div class="max_l">Max</div>
                    <div class="max_v">21</div>
                </div>
                <div class="line space-b">
                    <div class="name">Penrith</div>
                    <div class="wx">Sunny.</div>
                    <div class="min_l">Min</div>
                    <div class="min_v">9</div>
                    <div class="max_l">Max</div>
                    <div class="max_v">22</div>
                </div>
            </div>
            <h3 xmlns="" class="day">Forecast for Sunday</h3>
            <p xmlns="" class="sl">Mostly sunny. Light winds.</p>
            <div xmlns="" class="grid">
                <div class="line space-b">
                    <div class="name">City Centre</div>
                    <div class="wx">Mostly sunny.</div>
                    <div class="min_l">Min</div>
                    <div class="min_v">10</div>
                    <div class="max_l">Max</div>
                    <div class="max_v">21</div>
                </div>
                <div class="line space-b">
                    <div class="name">Penrith</div>
                    <div class="wx">Sunny.</div>
                    <div class="min_l">Min</div>
                    <div class="min_v">6</div>
                    <div class="max_l">Max</div>
                    <div class="max_v">23</div>
                </div>
            </div>
            <h3 xmlns="" class="day">Forecast for Monday</h3>
            <p xmlns="" class="sl">Becoming cloudy. Isolated showers later in the day. Winds west to southwesterly averaging up to 25 km/h.</p>
            <div xmlns="" class="grid">
                <div class="line space-b">
                    <div class="name">City Centre</div>
                    <div class="wx">Shower or two developing.</div>
                    <div class="min_l">Min</div>
                    <div class="min_v">13</div>
                    <div class="max_l">Max</div>
                    <div class="max_v">22</div>
                </div>
                <div class="line space-b">
                    <div class="name">Penrith</div>
                    <div class="wx">Shower or two developing.</div>
                    <div class="min_l">Min</div>
                    <div class="min_v">10</div>
                    <div class="max_l">Max</div>
                    <div class="max_v">22</div>
                </div>
            </div>
            <h3 xmlns="" class="day">Forecast for Tuesday</h3>
            <p xmlns="" class="sl">Sunny. Light winds tending north to northeasterly up to 20 km/h during the evening.</p>
            <div xmlns="" class="grid">
                <div class="line space-b">
                    <div class="name">City Centre</div>
                    <div class="wx">Sunny.</div>
                    <div class="min_l">Min</div>
                    <div class="min_v">12</div>
                    <div class="max_l">Max</div>
                    <div class="max_v">19</div>
                </div>
                <div class="line space-b">
                    <div class="name">Penrith</div>
                    <div class="wx">Sunny.</div>
                    <div class="min_l">Min</div>
                    <div class="min_v">10</div>
                    <div class="max_l">Max</div>
                    <div class="max_v">19</div>
                </div>
            </div>
            <h3 xmlns="" class="day">Forecast for Wednesday</h3>
            <p xmlns="" class="sl">Isolated showers during the morning. Sunny afternoon. Winds northwesterly averaging up to 25 km/h tending westerly up to 35 km/h during the morning.</p>
            <div xmlns="" class="grid">
                <div class="line space-b">
                    <div class="name">City Centre</div>
                    <div class="wx">Shower or two clearing.</div>
                    <div class="min_l">Min</div>
                    <div class="min_v">12</div>
                    <div class="max_l">Max</div>
                    <div class="max_v">20</div>
                </div>
                <div class="line space-b">
                    <div class="name">Penrith</div>
                    <div class="wx">Shower or two clearing.</div>
                    <div class="min_l">Min</div>
                    <div class="min_v">8</div>
                    <div class="max_l">Max</div>
                    <div class="max_v">21</div>
                </div>
            </div>
            <p xmlns="" class="dt">The next routine forecast will be issued at 4:20 pm&nbsp;EST&nbsp;Thursday.</p>
            <p xmlns="" class="p-id">* Calls to 1300 numbers cost around 27.5c incl. GST, higher from mobiles or public phones.</p>
        </div>
</html>
  • 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-16T18:44:20+00:00Added an answer on May 16, 2026 at 6:44 pm

    The ‘bad’ image looks exactly like how the HTML would render if the CSS wasn’t being applied. If you’re on a webmail, use something like HTTPFox to check if the browser’s even requesting the CSS files – they may be getting supressed as part of the anti-spam measure (no remote content loaded automatically). If it’s a real mail client (Outlook, Thunderbird, etc…) use a wire sniffer and do the same check.

    Most likely you’ll have to download the css and embed it inline, preferably somewhere after the <body> tag.

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

Sidebar

Related Questions

I have a strange problem with in-app billing RESTORE_TRANSACTION command. Every request RESTORE_TRANSACTION request
I have a strange issue with sending a mail with php, here is my
Good day! I have strange problem with Xcode 4.3. When I'm trying to run
I've got a strange problem. I have a client sending packets to my server,
I have a strange problem, I'm sending an SQL query through PHP: INSERT INTO
i have strange problem doing reporting: i have numerous clients with different issued invoices.
I have strange problem with receiving data from socket. On client im using air
I have a strange problem on ipv6 connection. I write down a simple client
I have a strange problem with IE. I have a sequence of forms on
I have a strange problem getting the color of the point that was touched.

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.