2

i need to send an email from java using sendEmail (http://caspian.dotconf.net/menu/Software/SendEmail/) but when i try to send it i get this error

sendEmail[11869]: Error: "-" is not a recognized option!

but if i put the same command in console (copy and paste the command from log) it works without any error.

Here my code:

String comm = "/opt/bin/sendEmail "
+ "-f \"***@***.com\" "
+ "-u \"REPORT\" "
+ "-m \"Report\" "
+ "-a \""+ pdfFileName +"\" "
+ "-s \"" host +"\" "
+ "-xu \""+ user +"\" "
+ "-xp \""+ password +"\" ";

for(String t:recipients)
    comm += "-t \""+ t  +"\" ";
log.info(comm); // It is correct! if i paste it in console it works
StringBuffer output = new StringBuffer();
Process p = Runtime.getRuntime().exec(comm);
p.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
while ((line = reader.readLine())!= null) {
    output.append(line + "\n");
}

Where am i doing wrong? Thanks

ilGiudice
  • 63
  • 1
  • 9

1 Answers1

0

After looking around i found this

Using Quotes within getRuntime().exec

Thanks to wonderb0lt and Wietlol

ilGiudice
  • 63
  • 1
  • 9