Spring: MimeMessageHelper encoding for attachments
<p>In Spring there is an option to set the encoding for mailing:</p>

<pre><code>MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true, "UTF-8");
</code></pre>

<p>This works great for subject and message of the email. </p>

<p>However if there is an attachment, the default encoding of the JVM will be used and specified in the Content-Type of the attachment part of the email (even if specifying encoding globally in the application and/or through arguments while deploying the jar). </p>

<p>Has anybody managed to tell Spring to use a specific encoding for mail attachments also? I know there is a way of doing it by using this structure:</p>

<pre><code>messageHelper.addAttachment(filename, new InputStreamSource() {
    @Override
    public InputStream getInputStream () throws IOException {
        return file.getInputStream();
        }
    }, "text/plain; charset=UTF-8");
</code></pre>

<p>The problem with this is that now I have to manually describe every attachment type and encoding. If there is no other way, then I guess this is the only way to go. </p>