Attachment to send through mail
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   philip_chittoor
Posted On:   Monday, August 19, 2002 04:40 PM

Hi, I need to know the following syntax will send the attachment from the client machine.I mean the attachment to send is residing in Cleint machine not in server. Do I want to know is it needed to upload the attachment file to server. I would appreciate you if any one can clarify this, Regards Philip Message message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); message.setSubject("Hello JavaMail Attachment"); // Create the message part BodyPart messageBodyPart = new MimeBodyPart(); // Fill the message messageBodyPart.   More>>

Hi,

I need to know the following syntax will send the attachment from the client machine.I mean the attachment to send is residing in Cleint machine not in server.
Do I want to know is it needed to upload the attachment file to server.
I would appreciate you if any one can clarify this,

Regards
Philip


Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
message.setSubject("Hello JavaMail Attachment");

// Create the message part
BodyPart messageBodyPart = new MimeBodyPart();

// Fill the message
messageBodyPart.setText("Here's the file");

// Create a Multipart
Multipart multipart = new MimeMultipart();

// Add part one
multipart.addBodyPart(messageBodyPart);

//
// Part two is attachment
//

// Create second body part
messageBodyPart = new MimeBodyPart();

// Get the attachment
DataSource source = new FileDataSource(filename);

// Set the data handler to the attachment
messageBodyPart.setDataHandler(new DataHandler(source));

// Set the filename
messageBodyPart.setFileName(filename);

// Add part two
multipart.addBodyPart(messageBodyPart);

// Put parts in message
message.setContent(multipart);

// Send the message
Transport.send(message);

   <<Less

Re: Attachment to send through mail

Posted By:   Christopher_Koenigsberg  
Posted On:   Tuesday, August 20, 2002 09:19 AM

Do I want to know is it needed to upload the attachment file to server


Yes, obviously.

About | Sitemap | Contact