Hello

I have a java program that sends mail to given gmail account.

Now i need to attach some files to mail and send them.

how can i do it??

// Set the host smtp address
Properties props = new Properties();
props.put("smtp.host", "smtp.server.com");

// create some properties and get the default Session
Session session = Session.getDefaultInstance(props, null);

// create a message
Message msg = new MimeMessage(session);

//adding an attachment
DataSource source = new FileDataSource("pathToFile/filename.zip");
msg.setDataHandler(new DataHandler(source));
msg.setFileName("filename.zip");