What is the process for inserting an image using nodemailer in Outlook?

I have been facing an issue while trying to send emails via Gmail using Nodemailer. The problem arises when the emails are opened on Outlook or Windows 10 Mail by the company, as I need to embed images like the logo and a background. While attaching the images works fine, I do not want them to appear as downloadable images when the email is opened.

I have tried different options, such as converting the image to base64 or using the image as a link. The latter only seems to work when using the following code:

<img data-imagetype="External" src="https://imgur.com/nTjrntx.png"/>

It seems to work when I include the

data-imagetype="External"
, but the issue arises when I try to set a background image using the background: url() property.

Is there a way to incorporate the data-imagetype within the background: url()?

Unfortunately, the HTML code provided below does not seem to work:

<main style="position: relative;display:flex;flex-direction:column;">
  <section style="z-index: 1;">
    <img data-imagetype="External"  src="https://imgur.com/JzrkOXb.png" />
  </section>
  <section style="position: absolute; z-index: 2;left:20%;right:20%;margin-top:10%">
      Hello People
  </section>
</main>

This seems to be related to the CSS style compatibility issues that mail clients can process.

As a result, here is the code I currently have:

 <!DOCTYPE html>
 <html >
 <body>
    <main style="padding-left:40px;padding-right:40px;border:0.5px solid #e5e5e5;margin-top:20px;border-radius:2px;background-image:url('https://imgur.com/JzrkOXb.png');background-repeat: no-repeat;background-position:center;background-size: 100% 100%;background-color:#2AEDC2;">
      <p style="font-size:20px;text-align:center;color:black"><strong>Hello People</strong></p><br />
      <p style="text-align:center;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis ut quam leo. Donec ut felis in arcu fermentum pulvinar.</p><br />
    
      <p style="text-align:center;">Regards!</p><br /><br /><br />
   </main>
</body>
</html>

Answer №1

Pushing boundaries, I managed to overlay the background image with text in this way:

<td valign="top" style="background-image:url(https://imgur.com/JzrkOXb.png);background-repeat: no-repeat;background-position:center;background-size: 100% 100%;>
 <!--[if gte mso 9]>
   <v:image data-imagetype="External" xmlns:v="urn:schemas-microsoft-com:vml" 
     fill="true" stroke="false" style=" border: 0;display: inline-block; 
     width:850px;height:350px;" src="https://imgur.com/JzrkOXb.png" />
   <v:rect data-imagetype="External" xmlns:v="urn:schemas-microsoft-com:vml" 
     fill="true" stroke="false" style=" border: 0;display: inline- 
     block;position: absolute; width:700px;height:250px;margin- 
     left:80px;margin-top:50px;">
   <v:fill  opacity="0%"  />
   <v:textbox inset="0,0,0,0">
 <![endif]--> 
 <div style="color:#808080">
   <p style="font-size:20px;text-align:center;"><strong>Dear people. 
     </strong></p><br />
   <p style="text-align:center;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus ut fringilla elit.</p><br />
   <p style="text-align:center;">!REGARDS!</p><br /><br /><br />
   <table width="100%" cellpadding="0px" cellspacing="0px"></table><br /><br /><br />
 </div>
 <!--[if gte mso 9]>
   </v:textbox>
   </v:fill>
   </v:rect>
   </v:image>
 <![endif]-->
</td>

Utilizing VML language was crucial for compatibility with various email clients like Windows 10 Mail, Outlook, Gmail, and Yahoo, as shown in the following line:

v:image data-imagetype="External" xmlns:v="urn:schemas-microsoft-com:vml ...

For further reference, here is some VML documentation: https://learn.microsoft.com/en-us/windows/win32/vml/web-workshop---how-to-use-vml-on-web-pages-----image--element

However, one challenge remains in web and mobile platforms where changing text color to black appears as white and vice versa.

I am thrilled to have solved this and hope it benefits others facing a similar issue :)

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

What is the functionality of array equals useState declarations in JavaScript?

Within ReactJS functional components, the following line enables the creation of: A variable to keep track of the current count A method to update the state when invoked Here's an example in JavaScript: let [count, setCount] = useState([]); Can you ...

Implementation issue with Hashids library in Vue.js causing functionality hiccups

I'm having trouble getting the library hashids to cooperate with vue.js The method I would like to use is: <template> <div class="container"> {{ hashids.encode('1') }} </div> </template> <script& ...

Animating the Ember Collection while paginating

Our team is currently developing an ember-pagination library to assist developers with pagination of items within an array collection. The library is already able to display content, enable pagination, and incorporate a typeahead feature for search funct ...

Developing a dynamic user interface using an Angular framework and populating it with

I am currently learning Angular (version 1) and facing an issue with my layout. I need to dynamically change the navigation based on the type of user that is logged in. To achieve this, I make an API request when the page loads to fetch the user object dat ...

Explore an array of elements to find the correct objectId stored in mongodb

element, I am faced with a challenge of searching through an array of objects to find a key that contains nested object id for populating purposes. Exploring My Object { service: 'user', isModerator: true, isAdmin: true, carts: [ ...

Middle-Click JavaScript Action

On the website I'm currently working on, there is a button that uses a sprite sheet animation and therefore needs to be set as a background image. I want the button to have a slight delay when clicked, so the animation can play before redirecting to a ...

Merge rxjs streams, identify modifications, and yield a single result

In the context of using Angular with .net Core WebApi, let's consider the development of a time management application designed to monitor task durations. The user initiates a task on the front end which triggers a timer displaying elapsed time. The ...

Is it secure to edit and save user HTML using JavaScript?

Consider this scenario: I've developed a cutting-edge tool for creating forms with Javascript. Users can utilize links to integrate html elements (such as input fields) and leverage TinyMCE for text editing. The data is saved through an autosave featu ...

Troubleshooting jQuery click event listeners and AJAX requests: Issue with second listener not functioning properly

There are two click listeners implemented on a page, one for a sub-navigation menu (which dynamically changes the list items in the menu) and another for a main menu (which dynamically changes the content in another section). <nav class="sub-nav"> ...

React-Redux Error: The function this.props.AppendCharacter is not defined

I have been looking for a solution to my issue but couldn't find anything that matches it. I am working on creating a calculator app using React & Redux, and whenever I click on one of the number buttons, I receive an error message saying "this.props. ...

Proper protocol for ensuring API database tables are synchronized

This is my first experience developing an application independently, handling the back-end, front-end, and design. I would appreciate some advice on structuring my back-end. Let's consider a scenario where there are tables for Users, Jobs, and Applic ...

Guide to making a button in jQuery that triggers a function with arguments

I've been working on creating a button in jQuery with an onClick event that calls a function and passes some parameters. Here's what I have tried so far: let userArray = []; userArray['recipient_name'] = recipient_name.value; userArray[ ...

Empty req.body when making a POST request in Node.js using Express (abnormal behavior)

This issue has proven to be quite common and challenging. Despite spending countless hours examining previous cases and solutions, none seem to be relevant in my situation. I am encountering a problem with a httpClient POST call from Angular 5 to a nodejs/ ...

What steps should be taken to enable the "You and moderator can reply" feature in a bot when sending proactive messages to channels?

A project I am currently working on involves creating a bot that sends proactive messages to channels. The client has requested that I include options like No reply or You and moderator can reply with the messages posted by the bot proactively. Here is wh ...

Can you explain the process of accessing data from [[PromiseValue]] while utilizing React hooks?

My current challenge involves fetching data from an API and utilizing it in various components through the Context API. The issue arises when I receive a response, but it's wrapped under a Promise.[[PromiseValue]]. How can I properly fetch this data ...

Tips on eliminating the blue color from a hyperlink within a button

Currently, I am in the process of designing an HTML email template. I have included a green button in the template and now need to eliminate the blue color from the hyperlink within the button. I have exhaustively tried different solutions such as using ! ...

Manage text, PDF, and image files in a MEAN stack app by uploading and fetching them from a MongoDB database using

I have been working on developing a piece of code that allows users to create a dynamic URL, upload a file by clicking a button on the page, and then download the same file in the same format when revisiting the URL. The functionality is similar to cl1p, b ...

How to get the total number of rows/records in a JSON store using ExtJS?

My dilemma involves a JSON store that provides data in JSON format. I am currently attempting to determine the number of rows or records in the JSON string. However, when utilizing the store.getCount() function, it consistently returns 0. Strangely, the ...

Scroll automatically to the following div after a brief break

On my website, the title of each page fills the entire screen before the content appears when you scroll down. I am interested in adding a smooth automatic scroll feature that will transition to the next section after about half a second on the initial "ti ...

Even after hashing the password, the comparison made by node.js bcrypt may still return false

I've been working on this problem for hours and I still can't figure it out. Here are the dependencies for my node.js app: "dependencies": { "bcrypt": "^3.0.0", "bluebird": "^3.5.1", "body-parser": "^1.18.3", "cors": "^2.8.4", "expres ...