File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
src/main/java/org/simplejavamail/converter/internal/mimemessage Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 11package org .simplejavamail .converter .internal .mimemessage ;
22
33import javax .activation .DataSource ;
4+ import javax .mail .EncodingAware ;
45import java .io .IOException ;
56import java .io .InputStream ;
67import java .io .OutputStream ;
1011/**
1112 * Allows given datasource to be renamed (from {@link javax.activation.DataHandler} perspective).
1213 */
13- class NamedDataSource implements DataSource {
14+ class NamedDataSource implements DataSource , EncodingAware {
1415
1516 /**
1617 * Original data source used for attachment.
@@ -69,4 +70,15 @@ public String getContentType() {
6970 public String getName () {
7071 return !valueNullOrEmpty (name ) ? name : dataSource .getName ();
7172 }
73+
74+ /**
75+ * Optimization to help Java Mail determine encoding for attachments.
76+ *
77+ * @return The encoding from the nested data source if it implements {@link EncodingAware} as well.
78+ * @see <a href="https://github.com/bbottema/simple-java-mail/issues/131">Bug report #131</a>
79+ */
80+ @ Override
81+ public String getEncoding () {
82+ return (this .dataSource instanceof EncodingAware ) ? ((EncodingAware ) this .dataSource ).getEncoding () : null ;
83+ }
7284}
You can’t perform that action at this time.
0 commit comments