aspose file tools*
The moose likes Java in General and the fly likes Sending email with multiple attachments not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Sending email with multiple attachments not working" Watch "Sending email with multiple attachments not working" New topic
Author

Sending email with multiple attachments not working

Eduardo Ponce de Leon
Ranch Hand

Joined: May 13, 2009
Posts: 99
Hi have a folder with many subfolders and within the subfolders there are multiple files. For every subfolder it goes out to a different persond and in the email I want to include the files withing that folder. I have that working, but I cannot seem to attache more than one file per email. Also I want to send one email with one destinatary and multiple carbon copies but everytime i send an email if i have 2 email sin my cc filed I get 3 copies of the same email in my sent folder, one for the To address and 2 for the cc adreeses. I am using Exjello library...please help me debug why I am only attaching one file from every subfolder, instead of 2+.
Thank you

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39884
    
  28
Too difficult a question for “beginning.” Moving thread.
Eduardo Ponce de Leon
Ranch Hand

Joined: May 13, 2009
Posts: 99
Ok...So I have figured out why I wasnt able to send multiple files... My only problem now is when I send the email i get a copy created for all destinataries instead of just 1 that incluedes all (cc´s and bcc´s)

Thank you..
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18910
    
    8

When you say "I get a copy..." could you explain what "I" and "get" mean in that sentence? A little bit more precision about what those copies are and where they are would be helpful.

Also I don't see why you would expect only one message when you're calling the sendMessage() method twice. I would expect your server to deal with at least two messages.
Eduardo Ponce de Leon
Ranch Hand

Joined: May 13, 2009
Posts: 99
Paul,
thanks for the reply. What I mean is the items created on my sent folder in Outlook. I udnerstand that I call the send method twice. But I havent figured out how to just call the send method once and send the email to both to-emails, cc-emails, and bcc-emails calling just one methond. I hope that explains the problem.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18910
    
    8

Well, in ordinary JavaMail you would add the recipients (all of them) to the message and then send the message. You're doing the first part of that right but the second part wrong. Unfortunately you're using that "ExchangeTransport" class which I never heard of. Does it not have a simple "sendMessage(msg)" method?
Eduardo Ponce de Leon
Ranch Hand

Joined: May 13, 2009
Posts: 99
The reason I am using this library is becuase I could not authenticate through JavaMail using exchange, with this library i have no problem. It uses JavaMail too. if you see my code i also add them to the message, but I cannot add them all to one array of InternetAddress
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18910
    
    8

I said that the code where you add the recipients to the message is correct, but then I spent a moment to look at the API documentation and noticed the existence of Message's "addRecipients" method. You should switch to using that.

What I said about the "sendMessage" still applies, though.

I should mention that I don't have any trouble authenticating to Exchange through JavaMail.
Eduardo Ponce de Leon
Ranch Hand

Joined: May 13, 2009
Posts: 99
ok.. what is the difference though?
if I do this...

then how do I send the message, if the cal method is of tyep mailer.sendMessage(Message m, InternetAddress[] a), i still not able to send just one message with all the destinataries (to,cc,bcc) in one email item.

Do you have some snippets of the authentication and sending a simple email message?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18910
    
    8

Eduardo Ponce de Leon wrote:then how do I send the message, if the cal method is of tyep mailer.sendMessage(Message m, InternetAddress[] a), i still not able to send just one message with all the destinataries (to,cc,bcc) in one email item.

I have no idea. As I said I don't know anything about that package. If that's the only "sendMessage" method it supports then apparently it doesn't support BCC recipients. (You could always combine the TO and CC recipients into one array.) Of course I say that without seeing the API documentation...

Do you have some snippets of the authentication and sending a simple email message?

Authentication:


Defining recipients:


Sending message:

Eduardo Ponce de Leon
Ranch Hand

Joined: May 13, 2009
Posts: 99
on user ive seen multiple combinations in the form of

domain\account:user@hotmail.com

which one should I use...I am going to try it...
Thanks!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18910
    
    8

When I authenticate to Exchange from JavaMail, the user name that I use is the same one that I use when I authenticate with my hands on a keyboard. At any rate if you want to know what to use in your environment, I don't think that guessing is going to help. Ask your Exchange administrator what you should be using.
Eduardo Ponce de Leon
Ranch Hand

Joined: May 13, 2009
Posts: 99
Will do thanks for the tips...
Do you have any idea what this error is about??

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18910
    
    8

Yes, I do. However you might want to have a look at the JavaMail FAQ (http://www.oracle.com/technetwork/java/faq-135477.html) so you don't have to ask about all of them as you encounter them. You'll find it in there, but I recommend reading through the whole thing. If you're going to be sending e-mail it's a good idea to understand how Internet e-mail works, and the FAQ tells you a lot of things about that.
 
Don't get me started about those stupid light bulbs.
 
subject: Sending email with multiple attachments not working