hi,
i have a class that takes parameters into construcor:
MailTransport(String fromAddress, String[] toAddress, String subject,
String messageBody, Object[] attachment, String[] contentType)
i did not write MailTransport. so i do not understand how to use the
Object[] attachment, i have just been typing null an ti seems to work.
however i would like to attach a .txt file
how to i make a text file into Object[]???
if unclear i will attempt to clear anything up as i know i might be
difficult to understand.
thanks for any input
-morc
Oliver Wong - 03 Feb 2006 18:17 GMT
> hi,
> i have a class that takes parameters into construcor:
[quoted text clipped - 13 lines]
>
> thanks for any input
Try reading the documentation for the class.
I know of org.apache.axis.transport.mail.MailTransport, but you're
probably not talking about that class, as it doesn't have a constructor like
the one you describe (it only has a zero argument constructor).
- Oliver
morc - 03 Feb 2006 18:48 GMT
no it is not a built in class. someone else created it. sorry for being
unclear.
anyhow i think i found a more simpler way to ask my question.
is it possible to cast a File into an Object[]??
if so please let me know how cuz i can't get the syntax right an im
pulling me hair.
thanks agian
-morc
Lothar Kimmeringer - 03 Feb 2006 19:15 GMT
> is it possible to cast a File into an Object[]??
Object[] arr = new Object[]{new File(myfile)};
But I rather doubt that this will work for your MailTransport-class.
Reading the documentation is definetly the best practise here.
Regards, Lothar

Signature
Lothar Kimmeringer E-Mail: spamfang@kimmeringer.de
PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)
Always remember: The answer is forty-two, there can only be wrong
questions!
opalpa@gmail.com opalinski from opalpaweb - 03 Feb 2006 19:12 GMT
This made me think of how emails can have multiple attachments. The
method might allow multiple attachments, that's why it takes an array.
You still don't know what kind of instances the method accepts. Inside
there might be some casting going on.
Good luck,
Opalinski
opalpa@gmail.com
http://www.geocities.com/opalpaweb/
opalpa@gmail.com opalinski from opalpaweb - 03 Feb 2006 19:17 GMT
javax.mail takes DataHandler instances, btw.
Opalinski
opalpa@gmail.com
http://www.geocities.com/opalpaweb/
morc - 03 Feb 2006 20:32 GMT
The Object[] is called attachments and this is what hte method does too
it.
Now ive been looking through the javax.mail documentation and i still
don't understand.
if ( attachments != null && contents != null ) {
if (attachments.length > 0 && contents.length > 0 &&
attachments.length == contents.length) {
for (int i = 0; i < contents.length; i ++) {
BodyPart bodyPart2 = new MimeBodyPart();
bodyPart2.setDataHandler(new DataHandler(attachments[i],
contents[i]));
multipart.addBodyPart(bodyPart2);
}
}
}
message.setContent(multipart);
message.saveChanges();
Transport trans = session.getTransport(to[0]);
//System.err.println("trans:"+trans);
trans.addTransportListener(this);
trans.connect();
trans.sendMessage(message, to);.
if anyone knows how i can get a .txt file too attach please tell me ..
im gona get fired :(
thanks
-morc
Roedy Green - 03 Feb 2006 23:22 GMT
>i did not write MailTransport. so i do not understand how to use the
>Object[] attachment, i have just been typing null an ti seems to work.
You have been trying vainly to make sense of the Javadoc right?
There are two easier sources of information. The Sun Javamail tutorial
with the listings and my own well-commented program, the bulk emailer
.See http://mindprod.com/products1.html#BULK
see http://mindprod.com/jgloss/javamail.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.