• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Error while sending Html Mail

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have created a java file which send mail in html format...
its giving me this error...
i dont understand wat is this all abt..
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/mail/util/SharedByteArrayInputStream
at email_test_html.main(email_test_html.java:114)
can nebody help??
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you please post the java code snippet where the error is occuring..
 
varun bihani
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My Code Snippet is
This is the java file that runs everyday by Cron..
I searches the databases and takes out the email and send html format mail
import java.io.PrintStream;
import java.sql.ResultSet;
import java.util.StringTokenizer;
import java.util.Vector;
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
class email_test_html
{
public email_test_html()
{
String to, subject = null, from = null,url = null;
String mailHost = "";
String protocol = null, host = null, user = null, password = null;
}
public Vector getCategoryVector(String s)
{
Vector vector = new Vector(1);
for(StringTokenizer stringtokenizer = new StringTokenizer(s, "~"); stringtokenizer.hasMoreTokens(); vector.addElement(stringtokenizer.nextToken()));
return vector;
}
public String getCategoryString(String s)
{
String s1 = "";
for(StringTokenizer stringtokenizer = new StringTokenizer(s, "~"); stringtokenizer.hasMoreTokens()
if(!s1.equals(""))
s1 = s1 + " or b.id =" + stringtokenizer.nextToken();
else
s1 = " b.id=" + stringtokenizer.nextToken();
return s1;
}
public static void main(String args[])
{
email_test_html email_test_html1 = new email_test_html();
String s1 = "";
int jj=0;
try
{
CConnection cconnection = new CConnection();
cconnection.connect();
String s2 = "select USERLOGIN,CATEGORY_MULTI_ID,EMAIL from T_REGISTRATION";
for(ResultSet resultset = cconnection.executeQuery(s2); resultset.next()
{
String s3=resultset.getString("USERLOGIN");
String s4 = resultset.getString("EMAIL");
String s5 = resultset.getString("CATEGORY_MULTI_ID");
String s6 = email_test_html1.getCategoryString(s5);
String s7 = "";
if(s4.equals("") || s4 == null)
s4 = "root@abc.com";
String s8 = "select p.id postid,p.CATEGORY_ID catid,c.name catname,b.id parentid,b.name parentname";
s8 = s8 + " from T_POST p ,T_CATEGORY c,T_CATEGORY b ";
s8 = s8 + " where p.status=1 and p.CATEGORY_ID= c.id and c.parent_id = b.id ";
if(!s6.equals(""))
if(s6.equals(" b.id=245"))
s8 =s8+ " and ( b.id =1 or b.id =49 or b.id =5 or b.id =12 or b.id =9 or b.id =15 or b.id =26 or b.id =22 or b.id =44 or b.id =40 or b.id =31 or b.id =245)";
else
s8 = s8 + " and ("+s6+") ";
s8 = s8 + " group by b.id,c.id ";
String s9 = "";
s7 = s7 + "<html><body>Dear " + s3 + ",\n\n";
s7 = s7 + "There is addition of new offers in the following category:\n";
s1 = "";
for(ResultSet resultset1 = cconnection.executeQuery(s8); resultset1.next()
{
String s10 = resultset1.getString("parentname");
String s11 = resultset1.getString("catname");
s1 = resultset1.getString("postid");
//System.out.println("Main Category--------------" + s10);
//System.out.println("Sub Category--------------" + s11);
//System.out.println("Post ID--------------" + s1);
String s12 = s10;
}
if(s1==null || s1.equals(""))
{
System.out.println("NO POSTING");
}
else{
System.out.println("1");
Properties props = new Properties();
System.out.println("2");
props.setProperty("mail.smtp.host", "");
System.out.println("3");
Session ssn = Session.getDefaultInstance(props);
System.out.println("4");
ssn.setDebug(true);
System.out.println("5");
Message msg = new MimeMessage(ssn);
System.out.println("6");
InternetAddress fromAdd = new InternetAddress("admin@chemicalhouse.com");
System.out.println("7");
msg.setFrom(fromAdd);
System.out.println("8");
msg.setSubject("Entry Posting Mail");
System.out.println("9");
InternetAddress toAdd = new InternetAddress("varunbihani@rediffmail.com");
System.out.println("10");
msg.addRecipient(Message.RecipientType.TO, toAdd);
System.out.println("11");
msg.setContent(s7, "text/html");
Transport.send(msg);
//sent=true;
}
}
}
catch(Exception exception)
{
System.out.println("EEEEEEERRRRRRRRROOOOOOORRRR" + exception);
}
}
}
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic