cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Error while attaching document in mail

Former Member
0 Likes
144

Hi,

I am trying to attach a file in mail, I wrote the below code:

// Set a file as an attachment. Uses JAF FileDataSource.

// Create and fill first part

MimeBodyPart p1 = new MimeBodyPart();

p1.setText("abcd");

// Create second part

MimeBodyPart p2 = new MimeBodyPart();

// Put a file in the second part

String fileName = "try.txt";

DataSource fds = new FileDataSource(fileName);

p2.setDataHandler(new DataHandler(fds));

p2.setFileName(fileName);

// Create the Multipart. Add BodyParts to it.

Multipart mp = new MimeMultipart();

mp.addBodyPart(p1);

mp.addBodyPart(p2);

// Set Multipart as the message's content

msg.setContent(mp);

Transport.send(msg);

But getting error:

Error executing script: Sourced file: inline evaluation of: ``import com.sap.odp.api.util.; import java.util.; import javax.mail.*; import j . . . '' : Method Invocation Transport.send.

Please suggest if I am missing something.

Thanks,

Saloni

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Likes

Resolved.

Filename path was not correct.