Getting an exception
sir i m Getting an following exception while sending a mail with attachment
value ofsession is javax.mail.Session@192d604
value of mimemessage is javax.mail.internet.MimeMessage@120b2da
value of internetaddress is
[email protected]** length of attachment is 1
** value of attachment is
[email protected] Harini 2 10
240809 Bang SoftWare Engg 10000
javax.mail.MessagingException: IOException while sending message;
nested exception is:
java.io.FileNotFoundException:
[email protected] Harini
2 10 240809 Bang SoftWare Engg 10000 (The filename, directory n
ame, or volume label syntax is incorrect)
method is
//Send Mail With Attachment
public String sendMailWithAttachment(String from,String to,String ccList,String bccList, String subject,String matter,
PrintWriter out,String attachment[])
{
String status="success",cc="",bcc="",sentlist="",notsent="",isError=null;
boolean isSent=true;
String host = " ";
String fromMail =from;
////// setting host
host = this.getMailHost ();
try{
Properties props = System.getProperties();
if (host != null)
props.put("mail.smtp.host",host);
////// Get a Session object
Session session1 = Session.getDefaultInstance(props, null);
////// setting from address
Message msg = new MimeMessage(session1);
if (fromMail != null)
msg.setFrom(new InternetAddress(fromMail));
else
msg.setFrom();
/////// setting to address
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to, true));
/////// setting subject
msg.setSubject(subject);
/////// setting mimemultipart
MimeMultipart mp = new MimeMultipart();
mp.setSubType("related");
/////// setting matter
MimeBodyPart mbp1= new MimeBodyPart();
mbp1.setContent(matter,"text/html");
mp.addBodyPart(mbp1);
for(int i=0;i < attachment.length;i++)
{
System.out.println("** length of attachment is "+attachment.length);
if(attachment[i]!=null && attachment[i].length()> 0 || !attachment[i].equalsIgnoreCase("null") || attachment[i].equals(""))
{
try{
///////setting mimebodypart
MimeBodyPart mbp2 = new MimeBodyPart();
////// attach the file to the message
System.out.println("** value of attachment is "+attachment[i]);
FileDataSource fds = new FileDataSource(attachment[i]);
mbp2.setDataHandler(new DataHandler(fds));
mbp2.setFileName(fds.getName());
// mbp2.setFileName(attachment);
mbp2.setFileName(attachment[i]);
/////// adding the file to mimebosypart
mp.addBodyPart(mbp2);
}catch(Exception e){
System.out.println("Send Mail exception "+e.toString());
}
}else {
System.out.println("If attachment failed ");
}//if
}//for
///// add the Multipart to the message
msg.setContent(mp);
msg.setSentDate(new Date());
if(ccList.length() == 0 && bccList.length() == 0)
{
//// send the message
Transport.send(msg);
}
// ************* CC ********************
if(ccList.length() != 0)
{
StringTokenizer gr=new StringTokenizer(ccList,",");
while(gr.hasMoreTokens())
{
try{
StringBuffer send = new StringBuffer("");
int i = 0;
do {
cc=gr.nextToken().trim();
///////If condition is given to filter invalid email addresses which may be there as a result of direct porting
if ((cc.indexOf(".") >0) && (cc.indexOf("@") >0))
{
send.append(cc+",");
++i;
}
}while (gr.hasMoreTokens());
// to set status before sending the message
status += "Before";
msg.setRecipients(Message.RecipientType.CC,InternetAddress.parse(send.toString(), true));
//// send the message
Transport.send(msg);
// status changed into After
status += "After";
///// List of the email address to send message
sentlist=sentlist+send.toString()+" , ";
}catch(Exception e){
isError="yes";
notsent=notsent+cc+" , ";
}//catch
}//while ends
}//if
// ************* BCC ********************
if(bccList.length() != 0)
{
StringTokenizer gr=new StringTokenizer(bccList,",");
while(gr.hasMoreTokens())
{
try{
StringBuffer send = new StringBuffer("");
int i = 0;
do {
bcc=gr.nextToken().trim();
///////If condition is given to filter invalid email addresses which may be there as a result of direct porting
if ((bcc.indexOf(".") >0) && (bcc.indexOf("@") >0))
{
send.append(bcc+",");
++i;
}
}while (gr.hasMoreTokens());
// to set status before sending the message
status += "Before";
msg.setRecipients(Message.RecipientType.BCC,InternetAddress.parse(send.toString(), true));
///// send the message
Transport.send(msg);
// status changed into After
status += "After";
///// List of the email address to send message
sentlist=sentlist+send.toString()+" , ";
}catch(Exception e){
isError="yes";
notsent=notsent+cc+" , ";
System.out.println("Exception in ::"+e.toString());
}//catch
}//while ends
}//if
////// check the email id's whether it is Valid EmailId or not ,if it is not Valid Display Unable to Deliver message
if(!isSent || isError !=null)
{
try{
status="Sorry...we could not deliver mail to <br> "+(notsent.replace(',',' ')).trim()+" <br> the above mentioned ID's may be invalid.";
}catch(Exception exe){ out.println(exe.toString()); }
}else{
try{
status="Message has been successfully delivered to <br> "+(sentlist.replace(',',' ')).trim()+" .";
}catch(Exception e){ out.println(e.toString());}
}//if
}catch(Exception ex){
System.out.println(ex.toString());
}
return status;
}// sendMailWithAttachment()
please help me sir if any changes
thanks in advance ....
***Successfull***true
View Answers
Related Tutorials/Questions & Answers:
Getting exception in hello worldGetting exception in hello world I run your hibernate5 "hello world" program. But,
getting an
exception:
ERROR: Table 'mydb.employee' doesn't exist
Exception in thread "main" javax.persistence.PersistenceException
Advertisements
Getting exception in hello worldGetting exception in hello world I run your hibernate5 "hello world" program. But,
getting an
exception:
ERROR: Table 'mydb.employee' doesn't exist
Exception in thread "main" javax.persistence.PersistenceException
Getting an exception - JSP-ServletGetting an exception Dear Sir ,
While sending a mail am
getting an following
exception
javax.mail.MessagingException: 554 mail server permanently rejected message (#5.
3.0)so how to over come from this please help
Getting an exception - JSP-ServletGetting an exception thanks sir for u r reply ,but i already added that jar file sir even though i m
getting an
exception sir please help me sir ...
thanks in advance.. Hi Friend,
You can do one thing, replace
Getting an exception - JSP-ServletGetting an exception
sir i am
Getting following
exception when...(cellStoreVector);
}
} catch (
Exception e) {
e.printStackTrace... running it will throwing an
exception
please help me sir
thanks
Getting an exception - JSP-ServletGetting an exception sir i m
Getting an following
exception while... sending message;
nested
exception is:
java.io.FileNotFoundException...);
}catch(
Exception e){
System.out.println("Send Mail
exception I am getting this exception I am
getting this
exception Exception in thread "main" org.hibernate.exception.GenericJDBCException: Cannot open connection
at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java
Getting an exception - JSP-ServletGetting an exception Dear sir,while executing this code i am
getting... of a is " + f);
}
}
//following is an
exception
org.apache.jasper.JasperException: An
exception occurred processing JSP page /jsp/newTestMES3.jsp at line
Getting an exception - JSP-ServletGetting an exception sir i changed to that ie
InputStream myInput1...
exception please help me sir if an changes tel me sir
thanks in advance...);
}
cellVectorHolder.addElement(cellStoreVector);
}
} catch (
Exception e
Getting an exception - JSP-ServletGetting an exception sir i used u r code for sending a mass email by reading an excel sheet,but i am
getting a following error so please help me if any changes in code .
thanks in advance..
java.io.IOException: Invalid
Getting an exception - JSP-ServletGetting an exception sir i used u r code for sending a mass email by reading an excel sheet,but i am
getting a following error so please help me if any changes in code .
thanks in advance..
java.io.IOException: Invalid
Getting exception in Assocation & Join. - HibernateGetting exception in Assocation & Join. select product0_.id as id0...)
exception setting property value with CGLIB (set hibernate.cglib.use_reflection...
org.hibernate.PropertyAccessException:
exception setting property value with CGLIB
Getting Null pointer Exception in the jsp pageGetting Null pointer
Exception in the jsp page I have developed this jsp page to store the data in database.While storing the value of check box in database I am
getting null pointer
exception in the following code
Getting Null pointer Exception in the jsp pageGetting Null pointer
Exception in the jsp page I have developed this jsp page to store the data in database.While storing the value of check box in database I am
getting null pointer
exception in the following code
Getting Null pointer Exception in the jsp pageGetting Null pointer
Exception in the jsp page I have developed this jsp page to store the data in database.While storing the value of check box in database I am
getting null pointer
exception in the following code
Getting Null pointer Exception in the jsp pageGetting Null pointer
Exception in the jsp page I have developed this jsp page to store the data in database.While storing the value of check box in database I am
getting null pointer
exception in the following code
using spring rmi+maven but i am getting this exceptionusing spring rmi+maven but i am
getting this exception D:\Nexustool... ---
java.rmi.ServerException: RemoteException occurred in server thread; nested
exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested
exception ExceptionException public class FooException extends
Exception {
public...");
}
public void calculate() throws FooException,
Exception
{
try {
int....
ex.printStackTrace();
System.exit(1);
} catch(
Exception ex
exceptionexception wHEN RUNTIME
EXCEPTION CLASS IS SUB OF
EXCEPTION CLASS HOW CAN'T HANDLE UNCHECKED
EXCEPTION exceptionexception chek in and check out
exception in java
Please visit the following link:
Checked and Unchecked
Exception exception arguments are not equalto two,throw a user defined
exception "invalid parameter
exception" ,otherwise display the two parameters.
Here is an example... is not equal to two then invalid parameter
exception is thrown ,otherwise display the two
exceptionexception what is the use of catch block even though we have predefined
exception object
exceptionexception example for numberformat
exception
Hi Friend,
Try the following code:ADS_TO_REPLACE_1
class NumberFormatExceptionEx...);
}
catch(
Exception e){
System.out.println(e
exception defined checked
exception ââ?¬Å?InvalidCharcterFoundExceptionââ?¬Â? and creater a block of codes that will handle the
exception ExceptionException whis is the Arithmetic
Exception in java? or define Arithmetic
Exception with exp?
Arithmetic
Exception occurs, when you divide a number by zero.
Example
public class TryCatch {
public static void main
Exception Exception I was creating a table dynamically but it shows
exception i.e shown down
Suplier created0
Suplier created0
Suplier created0
Product created0
Product created0
Product created0
Product created0
could not fetch initial
exceptionuser defined unchecked exception can we create user defined unchecked exceptions? if so what is the exact use of it in real time?
Please visit the following links:
http://www.roseindia.net/java/java-
exception/user
exceptionexception Identify the reason for SQLException
exception, which is encountered when the
developer tries to run the following code snippet to insert...");
ps.executeUpdate();
}
catch(
Exception e
Getting NumberFormatExceptionGetting NumberFormatException Hello Sir, I'm using Integer.parseInt... also used Integer.parseInt(String str, int radix) but it also throws the
exception... it in a JSP it continuously throws the
exception. below is the code I used. Please
Exception - StrutsException - java.lang.reflect.InvocationTargetException java.lang.reflect.InvocationTargetException i am
getting the foregoing error ...can anyone...: java.lang.reflect.InvocationTargetException: This is a checked
exception that extends
Exception Class thrown
exception - Strutsexception Hi,
While try to upload the example given by you in struts I am
getting the
exception
javax.servlet.jsp.JspException: Cannot...:
Exception in JSP: /FileUpload.jsp:10
7:
8:
9:
10:
11:
12:
13
getting variables getting variables how to get variables from servlet program to webservice program
Getting an error :(Getting an error :( I implemented the same code as above..
But
getting this error in console...
Console
Oct 5, 2012 10:18:14 AM... loadOnStartup
SEVERE: Servlet /SpringMVC threw load()
exception Exception in thread Exception in thread Hi,
I have created a java file for sending...
but when i am trying to run following command I am
getting an error.
java -cp D:\mail.jar SendMailTLSDFC
Exception in thread "main" java.lang.NoClassDefFoundError
getting the emplogetting the emplo I have one table "EMPLOYEEMASTER" contains 'emp id', 'employee name'
for eg:
emp id employee name... kumar
i want the sql statement for
getting like
Exception in jsf applicationException in jsf application when i am running application i am
getting org.apache.commons.logging.LogConfigurationException
and HTTP Status 404 -The requested resource () is not available
Exception so i want to know reason
exception handlingexception handling what is the information of
exception handling?
Have a look at the following link:
Java
Exception Handling
exception handlingexception handling what is the information of
exception handling?
Have a look at the following link:
Java
Exception Handling
exception handlingexception handling what is the information of
exception handling?
Have a look at the following link:
Java
Exception Handling
exception handlingexception handling what is the information of
exception handling?
Have a look at the following link:
Java
Exception Handling
exception handlingexception handling what is the information of
exception handling?
Have a look at the following link:
Java
Exception Handling
exception handlingexception handling what is the information of
exception handling?
Have a look at the following link:
Java
Exception Handling
exception handlingexception handling what is the information of
exception handling?
Have a look at the following link:
Java
Exception Handling
exception handlingexception handling what is the information of
exception handling?
Have a look at the following link:
Java
Exception Handling