A program to recognize and reward our most engaged community members
<?xml version="1.0" encoding="UTF-8" standalone="no"?><process version="5.2.008"> <context> <input/> <output/> <macros/> </context> <operator activated="true" class="write_excel" compatibility="5.2.008" expanded="true" height="76" name="Write Excel (2)" width="90" x="112" y="120"> <parameter key="excel_file" value="D:\carpeta/archivo.xls"/> <parameter key="file_format" value="xls"/> <parameter key="encoding" value="SYSTEM"/> <parameter key="sheet_name" value="RapidMiner Data"/> <parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/> <parameter key="number_format" value="#.0"/> </operator></process><?xml version="1.0" encoding="UTF-8" standalone="no"?><process version="5.2.008"> <context> <input/> <output/> <macros/> </context> <operator activated="true" class="execute_program" compatibility="5.2.008" expanded="true" height="76" name="Execute Program" width="90" x="246" y="120"> <parameter key="command" value="cmd /c start \carpeta\macro.xlsm"/> <parameter key="log_stdout" value="true"/> <parameter key="log_stderr" value="true"/> </operator></process><?xml version="1.0" encoding="UTF-8" standalone="no"?><process version="5.2.008"> <context> <input/> <output/> <macros/> </context> <operator activated="true" class="execute_script" compatibility="5.2.008" expanded="true" height="76" name="Interno" width="90" x="447" y="120"> <parameter key="script" value="import java.util.Properties; import javax.activation.DataHandler; import javax.activation.DataSource; import javax.activation.FileDataSource; import javax.mail.*; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMultipart; import java.text.SimpleDateFormat; public class MailWithAttachment { public static void main(String []args) throws Exception { SimpleDateFormat formateador = new SimpleDateFormat("dd/MM/yyyy H"); String host = "smtp.gmail.com";//host name String from = "direccion@mail.com";//sender id String to = "persona@mail.com"; String nombre = "Resultado.xlsx"; String pass = "pass";//sender's password String fileAttachment = "D:\\carpeta\\archivo.xlsx";//file name for attachment //system properties Properties prop = System.getProperties(); // Setup mail server properties prop.put("mail.smtp.gmail", host); prop.put("mail.smtp.starttls.enable", "true"); prop.put("mail.smtp.host", host); prop.put("mail.smtp.user", from); prop.put("mail.smtp.password", pass); prop.put("mail.smtp.port", "587"); prop.put("mail.smtp.auth", "true"); //session Session session = Session.getInstance(prop, null); // Define message MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); message.addRecipient(Message.RecipientType.TO,new InternetAddress(to)); message.setSubject("Mensaje"); // create the message part MimeBodyPart messageBodyPart = new MimeBodyPart(); //message body messageBodyPart.setText("Este es el mensaje y un archivo adjunto."); Multipart multipart = new MimeMultipart(); multipart.addBodyPart(messageBodyPart); //attachment messageBodyPart = new MimeBodyPart(); DataSource source = new FileDataSource(fileAttachment); messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setFileName(nombre); multipart.addBodyPart(messageBodyPart); message.setContent(multipart); //send message to reciever Transport transport = session.getTransport("smtp"); transport.connect(host, from, pass); transport.sendMessage(message, message.getAllRecipients()); transport.close(); } }"/> <parameter key="standard_imports" value="true"/> </operator></process>