You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Ashish Naik <as...@mahindrabt.com> on 2004/06/03 14:01:32 UTC

How to attach a file to email

I am trying to send an email with attachment. The code below sends the file
in-line. How to send as attachment?

client.setSender(this.senderEmail);
client.addRecipient(this.recepientEmailAddress);
header = new SimpleSMTPHeader(this.senderEmail, this.recepientEmailAddress,
this.emailSubject);

fileReader = new FileReader(fileName);
writer = client.sendMessageData();

if (writer != null)
{
 writer.write(header.toString());
 Util.copyReader(fileReader, writer);
 writer.close();
 client.completePendingCommand();
}



Cheers,
Ashish Naik




*********************************************************
Disclaimer:          

This message (including any attachments) contains 
confidential information intended for a specific 
individual and purpose, and is protected by law. 
If you are not the intended recipient, you should 
delete this message and are hereby notified that 
any disclosure, copying, or distribution of this
message, or the taking of any action based on it, 
is strictly prohibited.

*********************************************************
Visit us at http://www.mahindrabt.com