mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-10-01 17:06:23 +08:00
Download an email
An option is available in the reply drop-down called "Download Email", clicking this will prompt the user for the output directory
This commit is contained in:
parent
1ce06f18ba
commit
aba6709e30
4 changed files with 43 additions and 5 deletions
BIN
app/internal_packages/message-list/assets/mail-download-icon.png
Normal file
BIN
app/internal_packages/message-list/assets/mail-download-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 601 B |
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
|
@ -11,6 +11,8 @@ import {
|
|||
Message,
|
||||
} from 'mailspring-exports';
|
||||
import { RetinaImg, ButtonDropdown, Menu } from 'mailspring-component-kit';
|
||||
import { ipcRenderer, SaveDialogReturnValue } from 'electron';
|
||||
import { dialog } from '@electron/remote';
|
||||
|
||||
interface MessageControlsProps {
|
||||
thread: Thread;
|
||||
|
@ -47,13 +49,24 @@ export default class MessageControls extends React.Component<MessageControlsProp
|
|||
select: this._onShowOriginal,
|
||||
};
|
||||
|
||||
const downloadEmail = {
|
||||
name: localized('Download email'),
|
||||
image: 'ic-dropdown-whitespace.png',
|
||||
// TODO: Image isn't working - in this folders assets folder though
|
||||
// image: 'mail-download-icon@2x.png',
|
||||
select: this._onDownloadEmail,
|
||||
};
|
||||
|
||||
if (!this.props.message.canReplyAll()) {
|
||||
return [reply, forward, showOriginal];
|
||||
return [reply, forward, showOriginal, downloadEmail];
|
||||
}
|
||||
const defaultReplyType = AppEnv.config.get('core.sending.defaultReplyType');
|
||||
return defaultReplyType === 'reply-all'
|
||||
? [replyAll, reply, forward, showOriginal]
|
||||
: [reply, replyAll, forward, showOriginal];
|
||||
|
||||
return (defaultReplyType === 'reply-all' ? [replyAll, reply] : [reply, replyAll]).concat(
|
||||
forward,
|
||||
showOriginal,
|
||||
downloadEmail
|
||||
);
|
||||
}
|
||||
|
||||
_dropdownMenu(items) {
|
||||
|
@ -121,7 +134,10 @@ export default class MessageControls extends React.Component<MessageControlsProp
|
|||
|
||||
_onShowOriginal = async () => {
|
||||
const { message } = this.props;
|
||||
const filepath = require('path').join(require('@electron/remote').app.getPath('temp'), message.id);
|
||||
const filepath = require('path').join(
|
||||
require('@electron/remote').app.getPath('temp'),
|
||||
message.id
|
||||
);
|
||||
const task = new GetMessageRFC2822Task({
|
||||
messageId: message.id,
|
||||
accountId: message.accountId,
|
||||
|
@ -142,6 +158,27 @@ export default class MessageControls extends React.Component<MessageControlsProp
|
|||
win.loadURL(`file://${filepath}`);
|
||||
};
|
||||
|
||||
_onDownloadEmail = async () => {
|
||||
const { message } = this.props;
|
||||
|
||||
const filepath = await dialog.showSaveDialog({
|
||||
filters: [{ name: 'Email', extensions: ['.eml'] }],
|
||||
defaultPath: `${message.subject} - ${new Date().toLocaleDateString(
|
||||
'sv-SE'
|
||||
)} - ${message.id.substring(0, 10)}.eml`,
|
||||
});
|
||||
|
||||
if (!filepath.canceled && filepath.filePath) {
|
||||
Actions.queueTask(
|
||||
new GetMessageRFC2822Task({
|
||||
messageId: message.id,
|
||||
accountId: message.accountId,
|
||||
filepath: filepath.filePath,
|
||||
})
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
_onLogData = () => {
|
||||
console.log(this.props.message);
|
||||
(window as any).__message = this.props.message;
|
||||
|
|
|
@ -187,6 +187,7 @@
|
|||
"Do you prefer a single panel layout (like Gmail) or a two panel layout?": "Do you prefer a single panel layout (like Gmail) or a two panel layout?",
|
||||
"Don’t show this again": "Don’t show this again",
|
||||
"Download All": "Download All",
|
||||
"Download Email": "Download Email",
|
||||
"Download Failed": "Download Failed",
|
||||
"Download Now": "Download Now",
|
||||
"Downloading Update": "Downloading Update",
|
||||
|
|
Loading…
Add table
Reference in a new issue