Ejemplo de envío de un correo electrónico con adjunto a través de Amazon en Java.

¿Alguien tiene un ejemplo de envío de un correo electrónico, con un archivo adjunto, a través de Amazon SES (en Java)?

Tal vez un poco tarde, pero puede usar este código (también necesita Java Mail):

public class MailSender { private Transport AWSTransport; ... //Initialize transport private void initAWSTransport() throws MessagingException { String keyID =  String secretKey =  MailAWSCredentials credentials = new MailAWSCredentials(); credentials.setCredentials(keyID, secretKey); AmazonSimpleEmailService ses = new AmazonSimpleEmailServiceClient(credentials); Properties props = new Properties(); props.setProperty("mail.transport.protocol", "aws"); props.setProperty("mail.aws.user", credentials.getAWSAccessKeyId()); props.setProperty("mail.aws.password", credentials.getAWSSecretKey()); AWSsession = Session.getInstance(props); AWStransport = new AWSJavaMailTransport(AWSsession, null); AWStransport.connect(); } public void sendEmail(byte[] attachment) { //mail properties String senderAddress = ; String recipientAddress = ; String subject = ; String text = ; String mimeTypeOfText = ; String fileMimeType = ; String fileName = ; initAWSTransport(); try { // Create new message Message msg = new MimeMessage(AWSsession); msg.setFrom(new InternetAddress(senderAddress)); msg.addRecipient(Message.RecipientType.TO, new InternetAddress(recipientAddress)); msg.setSubject(subject); //Text part Multipart multipart = new MimeMultipart(); BodyPart messageBodyPart = new MimeBodyPart(); messageBodyPart.setContent(text, mimeTypeOfText); multipart.addBodyPart(messageBodyPart); //Attachment part if (attachment != null && attachment.length != 0) { messageBodyPart = new MimeBodyPart(); DataSource source = new ByteArrayDataSource(attachment,fileMimeType); messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setFileName(fileName); multipart.addBodyPart(messageBodyPart); } msg.setContent(multipart); //send message msg.saveChanges(); AWSTransport.sendMessage(msg, null); } catch (MessagingException e){...} } } 

Tal vez un poco tarde también. Alternativa a enviar correo utilizando Java Mail y Amazon Raw Mail Sender

 public static void sendMail(String subject, String message, byte[] attachement, String fileName, String contentType, String from, String[] to) { try { // JavaMail representation of the message Session s = Session.getInstance(new Properties(), null); MimeMessage mimeMessage = new MimeMessage(s); // Sender and recipient mimeMessage.setFrom(new InternetAddress(from)); for (String toMail : to) { mimeMessage.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(toMail)); } // Subject mimeMessage.setSubject(subject); // Add a MIME part to the message MimeMultipart mimeBodyPart = new MimeMultipart(); BodyPart part = new MimeBodyPart(); part.setContent(message, MediaType.TEXT_HTML); mimeBodyPart.addBodyPart(part); // Add a attachement to the message part = new MimeBodyPart(); DataSource source = new ByteArrayDataSource(attachement, contentType); part.setDataHandler(new DataHandler(source)); part.setFileName(fileName); mimeBodyPart.addBodyPart(part); mimeMessage.setContent(mimeBodyPart); // Create Raw message ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); mimeMessage.writeTo(outputStream); RawMessage rawMessage = new RawMessage(ByteBuffer.wrap(outputStream.toByteArray())); // Credentials String keyID = "";//  String secretKey = "";//  AWSCredentials credentials = new BasicAWSCredentials(keyID, secretKey); AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(credentials); // Send Mail SendRawEmailRequest rawEmailRequest = new SendRawEmailRequest(rawMessage); rawEmailRequest.setDestinations(Arrays.asList(to)); rawEmailRequest.setSource(from); client.sendRawEmail(rawEmailRequest); } catch (IOException | MessagingException e) { // your Exception e.printStackTrace(); } } 

En 2014, algunas de las API de Amazon han cambiado. Aquí hay un ejemplo de trabajo:

http://mintylikejava.blogspot.hk/2014/05/example-of-sending-email-with-multipal.html