How to attach two csv files in mail using html

To attach two CSV files to an email using HTML, you can use the <a> tag to create a link to the files and set the href attribute to the file path. You can also use the content-disposition attribute to specify the file name and type.

Here is an example of how you can do this:

<a href="file1.csv" download="file1.csv">Attach File 1</a>
<a href="file2.csv" download="file2.csv">Attach File 2</a>

This will create two links that, when clicked, will download the corresponding CSV files.

If you want to attach the files to the email instead of downloading them, you can use the mailto protocol and set the attachment attribute to the file path. Here is an example:

<a href="mailto:[email protected]?subject=Example&attachment=file1.csv,file2.csv">Send Email with Attachments</a>

This will create a link that, when clicked, will open the email client with the specified subject and attach the two CSV files.

You can also use JavaScript to attach the files to the email. Here is an example using the mailto protocol:

<a href="javascript:window.location.href='mailto:[email protected]?subject=Example&attachment=file1.csv,file2.csv'">Send Email with Attachments</a>

This will create a link that, when clicked, will open the email client with the specified subject and attach the two CSV files.

Note that the mailto protocol is not supported by all email clients, and some clients may not allow attachments to be sent using this protocol.

You can also use a library like emailjs to send emails with attachments, here is an example:

const email = require('emailjs');

const server = email.server.connect({
  user: 'username',
  password: 'password',
  host: 'smtp.gmail.com',
  ssl: true
});

const msg = {
  text: 'Hello',
  from: '[email protected]',
  to: '[email protected]',
  attachment: [
    { path: 'file1.csv', type: 'text/csv' },
    { path: 'file2.csv', type: 'text/csv' }
  ]
};

server.send(msg, (err, message) => {
  if (err) {
    console.log(err);
  } else {
    console.log('Email sent successfully');
  }
});

This will send an email with the specified subject and attach the two CSV files.

Please note that you need to replace the username and password with your actual email credentials, and also make sure that the email client you are using supports attachments.