| Author |
Sending Mail in HTML for mat with Attachemnt
|
Raj kalaria
Ranch Hand
Joined: Sep 08, 2005
Posts: 70
|
|
Hi I am writing a code to send a mail (its only in JAVA no JSP ) it has an attachment and few instructions ------------------********----------------------------------------- The following task has arrived in your Documentum Inbox. Double-click the attached file to perform the task. FromRaj Sent:9/8/2005 9:49:19 AM Docbase:vmrdev01 Priority:Medium THe Instructions:kgggkgg ---------------------*****---------------------------------- Now I am able to send the attachment and the first line only that is " The following task has arrived in your Documentum Inbox. Double-click the attached file to perform the task." Now i want to send the remaining lines but in HTML format that is i want to used BOLD property. ---------------------- My code -------------------- // Get session Session session1 = Session.getDefaultInstance(props, null); // session1.setDebug(sessionDebug); System.out.println("session is created "); // Define message Message msg = new MimeMessage(session1); msg.setSentDate(new java.util.Date()); // Set the from address msg.setFrom(new InternetAddress(from)); // Set the to address InternetAddress[] address = {new InternetAddress(to)}; msg.addRecipients( Message.RecipientType.TO, address); // Set the subject msg.setSubject(document_name); // Set the content // changes msg.setText(task_perform); // Create the message part BodyPart messageBodyPart = new MimeBodyPart(); // Fill the message messageBodyPart.setText(task_perform); // messageBodyPart.setText(alokmessage); System.out.println(alokmessage); Multipart multipart = new MimeMultipart(); multipart.addBodyPart(messageBodyPart); // Part two is attachment messageBodyPart = new MimeBodyPart(); DataSource source = new FileDataSource(task_link); messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setFileName(task_link); multipart.addBodyPart(messageBodyPart); // Put parts in message // msg.setContent(multipart,"html"); ******************************************************* msg.setContent(multipart); ******************************************************** System.out.println("message is created "); // Send message try { Transport.send(msg); System.out.println("message sent "); sent = true; } catch (SendFailedException e ) { System.out.println ("the problem is " + e); } catch (MessagingException e ) { System.out.println("Could not find the attachemnt " + e); } if (sent) { System.out.println("the message has been sent"); File myFile = new File (task_link); boolean retval = myFile.delete(); if (retval) { System.out.println("The File was successfully Deleted"); } else { System.out.println("The File was not successfully Deleted"); } } ----------------------************------------------------------ now if i change the line msg.setContent(multipart,"html") it will give me error " [B]Could not find the attachment javaxmailinternet parse Excpeption
|
 |
Raj kalaria
Ranch Hand
Joined: Sep 08, 2005
Posts: 70
|
|
sorry the subject line is Sending Mail in HTML with Attachemnt and some content
|
 |
 |
|
|
subject: Sending Mail in HTML for mat with Attachemnt
|
|
|