java - Sending File in mail in a loop -
i have requirement send different xls files different email. have created 1 loop in i'm performing 2 action
1) creation of file in temp 2) attache file mail message , send across.
my problem file created i'm getting blank file without data in xls.
my code generate file below,
//in loop fos = new fileoutputstream(path1); wb.write(fos); //i think writing in progress , while file sent in mail hence getting blank destination = new file(path1); internetaddress = null; = new internetaddress("abc@gmail.com",stringpool.blank); mailmessage message=new mailmessage(to,to, "temp", createemailbody(email,numberofuser), true); message.addfileattachment(destination); mailserviceutil.sendemail(message);
do wb.flush()
, wb.close()
before sending , set break point check if file written before sending it. hope help.
Comments
Post a Comment