* Allow to directly pass a javax.mail.BodyPart to addPart().

This commit is contained in:
hns 2006-11-27 12:47:04 +00:00
parent 9a98f81710
commit fb77729856

View file

@ -9,9 +9,9 @@
* Copyright 1998-2006 Helma Software. All Rights Reserved.
*
* $RCSfile: Mail.js,v $
* $Author: czv $
* $Revision: 1.2 $
* $Date: 2006/04/24 07:02:17 $
* $Author: hannes $
* $Revision: 1.3 $
* $Date: 2006/06/28 20:06:03 $
*/
@ -43,6 +43,7 @@ helma.Mail = function(smtp) {
var DataHandler = Packages.javax.activation.DataHandler;
var Address = MAILPKG.Address;
var BodyPart = MAILPKG.BodyPart;
var Message = MAILPKG.Message;
var Multipart = MAILPKG.Multipart;
var Session = MAILPKG.Session;
@ -215,7 +216,12 @@ helma.Mail = function(smtp) {
obj = obj.unwrap();
}
var part = new MimeBodyPart();
var part;
if (obj instanceof BodyPart) {
// we already got a body part, no need to convert it
part = obj;
} else {
part = new MimeBodyPart();
if (typeof obj == "string") {
part.setContent(obj.toString(), "text/plain");
} else if (obj instanceof File) {
@ -227,6 +233,7 @@ helma.Mail = function(smtp) {
var source = new MimePartDataSource(obj);
part.setDataHandler(new DataHandler(source));
}
}
if (filename != null) {
try {
part.setFileName(filename.toString());