Package lmnd.model.command

Source Code of lmnd.model.command.SendEmail

package lmnd.model.command;

import java.io.File;
import java.util.Collection;
import javax.swing.JOptionPane;
import org.runningman.mailutils.Credentials;
import org.runningman.mailutils.MessageData;
import org.runningman.mailutils.SMTPSender;

/**
* Sends selected files via e-mail.
*/
public class SendEmail implements Command {
        public void perform(CommandData data) throws Exception {
                Collection<File> files =
                        (Collection<File>) data.getValue(Keys.SOURCE_FILES);
                Credentials credentials = (Credentials) data.getValue(Keys.CREDENTIALS);
                SMTPSender sender = new SMTPSender();
                sender.setCredentials(credentials);
                MessageData messageData = (MessageData) data.getValue(Keys.MESSAGE_DATA);
                messageData.addFiles(files);
                messageData.setSubject("Sending file.");
                messageData.setContent("");
                sender.send(messageData);
                JOptionPane.showMessageDialog(null, "Отправлено.");
        }

        public void undo() {
        }
}
TOP

Related Classes of lmnd.model.command.SendEmail

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.