Global.helma.Mail.addPart (obj, filename)
Sourcecode in /home/hannes/helma/modules/helma/Mail.js:
204:   this.addPart = function(obj, filename) {
205:           try {
206:               if (obj == null) {
207:                   throw new IOException(
208:                       errStr + ".addPart: method called with wrong number of arguments."
209:                   );
210:               }
211:               if (multipart == null) {
212:                   multipart = new MimeMultipart();
213:              }
214:              if (obj instanceof Wrapper) {
215:                  obj = obj.unwrap();
216:              }
217:  
218:              var part = new MimeBodyPart();
219:              if (typeof obj == "string") {
220:                  part.setContent(obj.toString(), "text/plain");
221:              } else if (obj instanceof File) {
222:                  // FIXME: the following line did not work under windows:
223:                  //var source = new FileDataSource(obj);
224:                  var source = new FileDataSource(obj.getPath());
225:                  part.setDataHandler(new DataHandler(source));
226:              } else if (obj instanceof MimePart) {
227:                  var source = new MimePartDataSource(obj);
228:                  part.setDataHandler(new DataHandler(source));
229:              }
230:              if (filename != null) {
231:                  try {
232:                      part.setFileName(filename.toString());
233:                  } catch (x) {}
234:              } else if (obj instanceof File) {
235:                  try {
236:                      part.setFileName(obj.getName());
237:                  } catch (x) {}
238:              }
239:              multipart.addBodyPart(part);
240:          } catch (mx) {
241:              res.debug(errStr + ".addPart(): " + mx);
242:              setStatus(MIMEPART);
243:          }
244:          return;
245:      }