Unwrap arguments to Java objects in addPart(). Also, if the part is a java.io.File,
set the part's file name if no explicit file name is given.
This commit is contained in:
parent
6da249a73d
commit
5647d2bfdc
1 changed files with 10 additions and 3 deletions
|
@ -232,6 +232,11 @@ public class MailObject extends ScriptableObject implements Serializable {
|
||||||
|
|
||||||
MimeBodyPart part = new MimeBodyPart();
|
MimeBodyPart part = new MimeBodyPart();
|
||||||
|
|
||||||
|
// if param is wrapped JavaObject unwrap.
|
||||||
|
if (obj instanceof Wrapper) {
|
||||||
|
obj = ((Wrapper) obj).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
if (obj instanceof String) {
|
if (obj instanceof String) {
|
||||||
part.setContent(obj.toString(), "text/plain");
|
part.setContent(obj.toString(), "text/plain");
|
||||||
} else if (obj instanceof File) {
|
} else if (obj instanceof File) {
|
||||||
|
@ -248,9 +253,11 @@ public class MailObject extends ScriptableObject implements Serializable {
|
||||||
if (filename != null && filename != Undefined.instance) {
|
if (filename != null && filename != Undefined.instance) {
|
||||||
try {
|
try {
|
||||||
part.setFileName(filename.toString());
|
part.setFileName(filename.toString());
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {}
|
||||||
// FIXME: error setting file name ... should we ignore this or throw an exception?
|
} else if (obj instanceof File) {
|
||||||
}
|
try {
|
||||||
|
part.setFileName(((File) obj).getName());
|
||||||
|
} catch (Exception x) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
multipart.addBodyPart(part);
|
multipart.addBodyPart(part);
|
||||||
|
|
Loading…
Add table
Reference in a new issue