The logo emerges from the background color, with the text consistently appearing in black

In my attempt to display a logo and text together in an Outlook page, I encountered an issue. The content from the HTML page appears different when sent to MS Outlook. Despite not using flexbox in my HTML code, Outlook interprets it differently. I am uncertain which stylesheet adjustments I need to make for the logo and text to match those on the HTML page.

Here is the HTML page image: https://i.sstatic.net/Apz5C.png

And here is how the logo and text appear in Outlook: https://i.sstatic.net/8CxUA.png

The picture extends beyond the blue background color, and the second text "This is Text2" appears as black instead of the specified white. How can I resolve this issue? See below for my style sheet and HTML code:


.logo {
	transform: translateX(2em);
}
.name1 {
	font-size: 25px;
	color: #e9c46a;
}

.name2 {
	font-size: 25px;
	color: #ffffff;
}

.container {
	padding-bottom: 40px;
}

.container img {
	width: 50px;
	height: 50px;
}

.small-image img {
	width: auto;
	height: 40px;
}

.collapse-border table {
	border-collapse: collapse;
	border-spacing: 0;
}

.font-aligned .name1 {
	vertical-align: bottom;
}

.font-aligned .name2 {
	vertical-align: top;
}
<div class="container">
	<table style="background-color: cadetblue;width:100%;">
		<tr>
			<td rowspan="3" width="100">
				<img src="https://placekitten.com/200/300" class="logo" />
			</td>
		</tr>
		<tr>
			<td class="name1" >This is Text1</td>
		</tr>
		<tr>
			<td class="name2">This is Text2</td>
		</tr>
	</table>
</div>

Below is the C# code used to send the HTML to Outlook:


SmtpClient client = new SmtpClient();
client.Credentials = new NetworkCredential("test", EmailPass);
client.Port = 200;
client.EnableSsl = true;
client.Host = "smtp.office365.com";
client.DeliveryMethod = SmtpDeliveryMethod.Network;

MailMessage mail = new MailMessage();
mail.IsBodyHtml = true;
mail.From = test;
mail.To.Add(new MailAddress("[email protected]"));
mail.Subject = "test";

using(StreamReader reader = new StreamReader(Server.MapPath("~/EmailTemplate.html")))
{
	body = reader.ReadToEnd();
}

mail.Body = body;

client.Send(mail);

Any assistance would be greatly appreciated.

Answer №1

If you're looking to address the image height issue, then consider implementing the following solution:

/* Utilize class name or selector like 'img' */
img {
    width: 2rem; /* 16 * 2 = 32px */
    height: 2rem;
    
    /* Choose the option that best fits your needs */
    object-fit: contain;
    /* Alternatively */
    object-fit: cover;

    /* For more details, refer to MDN Docs -> https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit */
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Guidelines for parsing a JSON response and retaining specific attributes

I am currently working on parsing the response from the following link: . My program is expected to receive a response like this: [ { "createdAt": "2015-06-15T13:10:43.000Z", "domain": "000.biz", " ...

How can I add page transitions to my simple HTML website?

Working on an internal website project for my office using vue.js has been a rewarding experience. I appreciate how easily it allows me to manage multiple pages with dynamic content and seamless transitions. Unfortunately, my IT department is hesitating to ...

UpdatePanel controls are currently not accessible due to an error with the object reference being null

In my project, there is an UpdatePanel containing a Label control named Label1, and a button called Button1 outside the panel. There is also another Label control named Label2 located outside the UpdatePanel. The goal is to update the text of Label1 when B ...

What is the best method to make the first input field the focus in BootStrap?

Is there a way to prioritize the focus on the initial input element in an HTML form without specifying an ID? How to set the focus to the first input element in an HTML form independent from the id? I'm working with BootStrap and ASP.NET MVC4. De ...

The filter search feature fails to return any results when data is inputted into the tables

I have implemented a filter search feature within two tables on my website. My goal is to retrieve the search results for a specific drink while keeping the table headings fixed in their positions. For instance, if I type "Corona" into the search box, I ...

The actions performed within an event listener function are undone once they have been carried out

I'm a newcomer to Javascript and I am currently experimenting with it. While browsing through a tutorial on w3schools, I came across an example of changing the color of a button after clicking on it. My idea was to take it a step further by loading a ...

Achieving a smooth sliding motion with the help of jQuery animation

Here is the code snippet: In HTML: <div> <div id="div1">12345</div> <div id="div2">67890</div> <div id="div3"><a href="#" id="slide">abcde</a></div> <div id="pad" style="display:non ...

Preventing multiple users from saving the same value for a field using ajax and C#: Best Practices

On my aspx page, I am collecting email addresses from users and making an ajax call like so: function CheckEmailExistence() { $.ajax({ url: "Handler.ashx", contentType: "application/json; charset=utf ...

Unable to view mobile version on HTML page / lack of responsiveness observed

<body> <nav class="navbar navbar transparent"> <div class="container-fluid logo"> <div class="navbar-header"> <a class="navbar-brand" href="#"> <img src="images/Logo.png" /> & ...

Is it possible to change the button class within a div while ensuring only the last one retains the change?

Here is a code snippet I'm using to switch between classes for buttons: $('button').on('click', function(){ var btn=$(this); if(btn.attr('class')=='tct-button'){ btn.removeClass('tct-button ...

`Month filter functionality optimized`

I have a flirty plugin installed on my website and it's working great except for one thing: I'd like the month category to be filtered in chronological order instead of alphabetically. Is there a way to achieve this? In simpler terms, how can I ...

Pagination functionality in TablePress allows for improved organization and

Currently, I am utilizing the TablePress plugin on my WordPress website and I am aiming to achieve a pagination layout similar to this illustration: . How can I modify the pagination to display the text 'page 1 of X' instead of 'previous&apo ...

Employing conditional statements in conjunction with styled components

Is there a way to style my PaymentBtn with the main styled Button but only apply the hover effect when the isLoading prop is activated, without changing anything else? I want the styling to remain the same except for the hover effect. Basic button export ...

Ways to utilize CSS for capturing user-inputted text in a text field

I have a question about incorporating user input text into CSS styling. Specifically, I am looking to create a color background option (#ffffff) where the designer can input their own color and have it displayed once saved in the body background style. Wh ...

I am searching for a way to apply a conditional class to the chosen element in react, as the toggle method does not

I'm working on customizing a dropdown menu and I want to add a functionality where if a parent li menu has an arrow class before the ul element, then clicking on that parent li menu will add a class called showMenu only to that specific sub-menu. Her ...

Having difficulty compiling Bootstrap css with grunt

After struggling for two days and finding numerous online tutorials, I still require assistance. My goal is to add a namespace to Bootstrap so that I can use it in Salesforce without conflicting with Salesforce's stylesheet. I plan on wrapping the boo ...

When I set my header as "fixed", it automatically adjusts the size of the header box

Looking to create a fixed-header that includes clickable links on the left and our logo on the right. Encountering an issue when trying to make the header take up the full width of the screen in its fixed position. The header's width seems to shrink ...

Ways to prevent the jQuery simple slider from transitioning slides while it is in an invisible state

There is a jQuery slider on my website that behaves strangely when I navigate away from the Chrome browser and return later. It seems to speed through all pending slides quickly when it was not visible. Now, I want the slider to pause when it becomes invi ...

Display the HTML code in its formatted text output

I am currently facing an issue while trying to take input from the user using the WYSIWYG text editor plugin. When I attempt to display the text in a label or paragraph, all the HTML tags become visible. For instance, @string str = "<b>sample text&l ...

Align text in the center of a static container

I am facing the challenge of aligning four h4 tags in the center of their respective fixed divs, all set to width: 100% to ensure their background-color: rgba(255, 255, 255, 0.5); covers the entire browser width. Despite trying various combinations of CSS ...