Thursday, May 6, 2021
HomeBloggingDownload Gmail Messages as EML Files in Google Drive

Download Gmail Messages as EML Files in Google Drive

- Advertisement -
- Advertisement -

This Google Script will assist you with downloading your email messages from Gmail to your Google Drive in the EML design.

Download Gmail Messages as EML Files in Google Drive

What is the EML Format

The .eml document design is famous for moving messages starting with one email program then onto the next since it conforms to the RFC 822 norm and hence can be locally opened inside Apple Mail and Microsoft Outlook. You can even open EML records inside Google Chrome by hauling the document from your work area onto another program table.

EML documents contains the email content (email body, header and encoded pictures and connections) as plain content in MIME design.

Download Gmail message as EML Files

Inside Gmail, open any email string, go to the 3-dab menu and pick “Download Message” from the menu. It will transform your present email message into an eml document and save it your work area.

Notwithstanding, in the event that you wish to robotize the cycle and download various messages as eml documents in your Google Drive, Apps Script can help.

const downloadEmails = () => {
  const sender = 'sender@domain.com';
  const threads = GmailApp.search(`from:${sender}`).slice(0, 10);
  threads.forEach((thread) => {
    const subject = thread.getFirstMessageSubject();
    const [message] = thread.getMessages();
    const rawContent = message.getRawContent();
    const blob = Utilities.newBlob(rawContent, null, `${subject}.eml`);
    const file = DriveApp.createFile(blob);
    Logger.log(subject, file.getUrl());
  });
};

The content looks for messages from the predetermined sender, gets the main email message and downloads it your Google Drive.

Forward Gmail as EML Attachment

In the event that you are to advance an email message as a connection, the .eml configuration might be suggested since it protects all the designing and connections of the first email string in a solitary document that can be appended to the email.

const forwardEmail = () => {
  const messageId = '123';
  const message = GmailApp.getMessageById(messageId);
  const rawContent = message.getRawContent();
  const blob = Utilities.newBlob(rawContent, null, `email.eml`);
  GmailApp.sendEmail('to@gmail.com', 'This email contains an eml file', '', {
    attachments: [blob],
  });
};

- Advertisement -
namanmahajanhttp://artistogram.in
I am a Multimedia artist, I am born and based on Dewas (M.P), I am working as a freelancer with various brands and different country. My expertise are Graphics designing, motion graphics, 2d/3d animation, advertising videos, cartoons designing, all types of packaging and branding designing, digital marketing, SEO, design website and app Developments etc...

Leave a Reply

- Advertisment -
- Advertisment -

Most Popular

- Advertisment -