/Api

Files

The Files API allows you to download files, such as message attachments, from Mailosaur.

Download an attachment

Downloads a single attachment. Simply supply the unique identifier for the required attachment.

Path parameters

  • Name
    id
    Type
    string
    Required
    required
    Description
    The identifier of the attachment to be downloaded.
Postman iconInsomnia icon
GET /api/files/attachments/:id
curl \
  -o example.png \
  -u api:YOUR_API_KEY \
  https://mailosaur.com/api/files/attachments/ATTACHMENT_ID
const fs = require('fs');

// ...

const file = await mailosaur.files.getAttachment('ATTACHMENT_ID');
fs.writeFileSync('example.png', file);
cy.mailosaurDownloadAttachment('ATTACHMENT_ID').then(file => {
  cy.writeFile('example.png', file, 'binary')
})
file = mailosaur.files.get_attachment('ATTACHMENT_ID').content
f = open('example.png', 'wb')
f.write(file)
f.close()
byte[] file = mailosaur.files().getAttachment("ATTACHMENT_ID");
Files.write(Paths.get("example.png"), file);
var file = mailosaur.Files.GetAttachment("ATTACHMENT_ID");
File.WriteAllBytes("example.png", file);
file = mailosaur.files.get_attachment('ATTACHMENT_ID')
File.open(first_attachment.file_name, 'wb') { |fp| fp.write(file) }
$file = $mailosaur->files->getAttachment("ATTACHMENT_ID");
$f = fopen("example.png", "w") or die("Unable to open file!");
fwrite($f, $file);
fclose($f);
var file, _ = m.Files.GetAttachment("ATTACHMENT_ID")
var err = os.WriteFile("example.png", file, 0644)
if err != nil {
  // handle error
}

Download EML

Downloads an EML file representing the specified email. Simply supply the unique identifier for the required email.

Path parameters

  • Name
    id
    Type
    string
    Required
    required
    Description
    The identifier of the email to be downloaded.
Postman iconInsomnia icon
GET /api/files/email/:id
curl \
  -o example.eml \
  -u api:YOUR_API_KEY \
  https://mailosaur.com/api/files/email/MESSAGE_ID
const fs = require('fs');

// ...

const file = await mailosaur.files.getEmail('MESSAGE_ID');
fs.writeFileSync('example.eml', file);
cy.mailosaurDownloadMessage('MESSAGE_ID').then(file => {
  cy.writeFile('example.eml', file, 'binary')
})
file = mailosaur.files.get_email('MESSAGE_ID').content
f = open('example.eml', 'wb')
f.write(file)
f.close()
byte[] file = mailosaur.files().getEmail("MESSAGE_ID");
Files.write(Paths.get("example.eml"), file);
var file = mailosaur.Files.GetEmail("MESSAGE_ID");
File.WriteAllBytes("example.eml", file);
file = mailosaur.files.get_email('MESSAGE_ID')
File.open(first_attachment.file_name, 'wb') { |fp| fp.write(file) }
$file = $mailosaur->files->getEmail("MESSAGE_ID");
$f = fopen("example.eml", "w") or die("Unable to open file!");
fwrite($f, $file);
fclose($f);
var file, _ = m.Files.GetEmail("MESSAGE_ID")
var err = os.WriteFile("example.eml", file, 0644)
if err != nil {
  // handle error
}