}
message.setFrom(new InternetAddress(from));
message.setSubject(subject);
BodyPart messageBodyPart = new MimeBodyPart();
//Added by Ryan Grier <ryan@centraview.com>
//Need to send email as plain text if
//it contains no html content.
String messageContext = "text/plain";
// Modified by Deepa
// User Preferences value will decide content type of the email. ie. Plain text or Html text
InitialContext ic = CVUtility.getInitialContext();
PreferenceLocalHome home = (PreferenceLocalHome)ic.lookup("local/Preference");
PreferenceLocal localPref = home.create();
localPref.setDataSource(this.dataSource);
UserPrefererences userPref = localPref.getUserPreferences(userId);
if(userPref != null)
if (userPref.getContentType() != null && userPref.getContentType().equals("PLAIN"))
{
messageContext = "text/plain";
}
else if ( userPref.getContentType() != null && userPref.getContentType().equals("HTML"))
{
messageContext = "text/html";
}
if(mailmessage.getContentType() != null && mailmessage.getContentType().equals("HTML") ){
messageContext = "text/html";
}
/* if ((body.indexOf("<") > -1) && (body.indexOf(">") > -1))
{
messageContext = "text/html";
} //end of if statement ((body.indexOf("<") > -1) && (body.indexOf(">") > -1))
else if ((body.indexOf("<") > -1) && (body.indexOf(">") > -1))
{
messageContext = "text/html";
} //end of if statement ((body.indexOf("<") > -1) && (body.indexOf(">") > -1))
*/
messageBodyPart.setContent(body, messageContext);
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
messageBodyPart = new MimeBodyPart();
HashMap attchmentids = mailmessage.getAttachFileIDs();
if ((attchmentids != null) && (attchmentids.size() != 0))
{
Set col = attchmentids.keySet();
Iterator itt = col.iterator();
int i = 0;
while (itt.hasNext())
{
String fileid = (String) itt.next();
String name = (String) attchmentids.get(fileid);
cvdl.setSql("email.savedraftattchment");
cvdl.setInt(1, messageid);
cvdl.setString(2, name);
cvdl.setInt(3, Integer.parseInt(fileid));
cvdl.executeUpdate();
cvdl.clearParameters();
i++;
CvFileFacade cvfile = new CvFileFacade();
CvFileVO cvfilevo = cvfile.getEmailAttachment(userId, Integer.parseInt(fileid), this.dataSource);
String path = cvfilevo.getPhysicalFolderVO().getFullPath(null, true) + cvfilevo.getName();
DataSource source = new FileDataSource(path);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(name);
multipart.addBodyPart(messageBodyPart);
} //end of while loop(itt.hasNext())
} //end of if statement ((attchmentids != null) && (attchmentids.size() != 0))
// delete mail from drafts