Feb 20

When using Javamail to send mail the Message-ID gets set when the message is actually sent. If you want to provide your own Message-ID then you need to subclass MimeMessage. You can then use that subclass to create your message.

public class CustomMimeMessage extends MimeMessage {

	public CustomMimeMessage(Session session) {
		super(session);
	}

	@Override
	protected void updateMessageID() throws MessagingException {
		setHeader("Message-ID", "objects-message-id");
	}	
}

written by objects \\ tags: , ,