even when the filetype is passed as “email”,
the file is uploaded as plain/text file
const request = require("request");
async function main(){
await request.post(
{
url: 'https://slack.com/api/files.upload',
formData: {
token: 'xoxb-token',
tile: 'Email',
filename: 'test_email',
filetype: 'email',
channels: 'C012345ABCD',
content: 'email_content_html'
`
}
},
async function (err, response) {
if(err){
console.log(err);
}else{
// just for debugging
console.log(response.body);
}
}
);
}
main();
the above code gives the response:
{"ok":true,"file":{"id":"asdfasdfas","created":asdfasdfasd,"timestamp":asdfasdf,"name":"test_email.txt","title":"test email","mimetype":"text/plain","filetype":"text","pretty_type":"Plain text","user":"asdfasdfasdf","user_team":"asdfasdfasdf","editable":true,"size":29262,"mode":"snippet","is_external":false,"external_type":"","is_public":true,"public_url_shared":false,"display_as_bot":false,"username":"","url_private":"https://files.slack.com/files-pri/asdfasdf-asdfasdf/test_email.txt","url_private_download":"https://files.slack.com/files-pri/adsfasdf-adsfasdf/download/test_email.txt",.........."groups":[],"ims":[],"has_more_shares":false,"has_rich_preview":false,"file_access":"visible"}}
It never shows email snippet no matter what I pass as “content”
The email
filetype
requires some specific logic that’s only accessible by Slack’s custom built integrations, I’m afraid.
As an alternative, you could create a text file or a pdf, and then upload it to Slack.