• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Sending Mail in HTML for mat with Attachemnt

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry the subject line is

Sending Mail in HTML with Attachemnt and some content
 
and POOF! You're gone! But look, this tiny ad is still here:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic