Message m = new Message(sb.toString());
m.setMimeType(Message.MIME_TEXT);
m.getAttachments().put(filename1, "text/html");
m.getAttachments().put(filename2, "text/html");
Message.sendMessage(recipients, "subject", m);
I've just needed to add only one attachment, using the same code, and on Android (only test) Gmail keeps saying it cannot attach the file:
Message m = new Message(sb.toString());
m.setMimeType(Message.MIME_TEXT);
m.getAttachments().put(filename1, "text/html");
Message.sendMessage(recipients, "subject", m);
I tried a whole bunch of things, thinking it was the file path, message name or content - nothing worked, until I changed the code to:
Message m = new Message(sb.toString());
m.setMimeType(Message.MIME_TEXT);
m.setAttachment(filename1);
m.setAttachmentMimeType("text/html");
Message.sendMessage(recipients, "subject", m);
So it appears if you only have one attachment you shouldn't use Message.getAttachments() - is that correct ?