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

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -