* Allow to directly pass a javax.mail.BodyPart to addPart().
This commit is contained in:
parent
9a98f81710
commit
fb77729856
1 changed files with 21 additions and 14 deletions
|
@ -9,9 +9,9 @@
|
||||||
* Copyright 1998-2006 Helma Software. All Rights Reserved.
|
* Copyright 1998-2006 Helma Software. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* $RCSfile: Mail.js,v $
|
* $RCSfile: Mail.js,v $
|
||||||
* $Author: czv $
|
* $Author: hannes $
|
||||||
* $Revision: 1.2 $
|
* $Revision: 1.3 $
|
||||||
* $Date: 2006/04/24 07:02:17 $
|
* $Date: 2006/06/28 20:06:03 $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ helma.Mail = function(smtp) {
|
||||||
var DataHandler = Packages.javax.activation.DataHandler;
|
var DataHandler = Packages.javax.activation.DataHandler;
|
||||||
|
|
||||||
var Address = MAILPKG.Address;
|
var Address = MAILPKG.Address;
|
||||||
|
var BodyPart = MAILPKG.BodyPart;
|
||||||
var Message = MAILPKG.Message;
|
var Message = MAILPKG.Message;
|
||||||
var Multipart = MAILPKG.Multipart;
|
var Multipart = MAILPKG.Multipart;
|
||||||
var Session = MAILPKG.Session;
|
var Session = MAILPKG.Session;
|
||||||
|
@ -215,7 +216,12 @@ helma.Mail = function(smtp) {
|
||||||
obj = obj.unwrap();
|
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") {
|
if (typeof obj == "string") {
|
||||||
part.setContent(obj.toString(), "text/plain");
|
part.setContent(obj.toString(), "text/plain");
|
||||||
} else if (obj instanceof File) {
|
} else if (obj instanceof File) {
|
||||||
|
@ -227,6 +233,7 @@ helma.Mail = function(smtp) {
|
||||||
var source = new MimePartDataSource(obj);
|
var source = new MimePartDataSource(obj);
|
||||||
part.setDataHandler(new DataHandler(source));
|
part.setDataHandler(new DataHandler(source));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (filename != null) {
|
if (filename != null) {
|
||||||
try {
|
try {
|
||||||
part.setFileName(filename.toString());
|
part.setFileName(filename.toString());
|
||||||
|
|
Loading…
Add table
Reference in a new issue