how to download .exe file from a POP3 server using JavaMail
Hi to all,
Iam unable to download the .exe file from a mailserver,it is giving exception like FileNotFound.iam successful to download all kind of files except .exe(installation file or i can say a software exe file).
what is the problem?
and this is my code
*********************
Message[] m=folder.getMessges();
dumpPart(m);
}
public static void dumpPart(Part p) throws Exception {
// if (p instanceof Message) dumpEnvelope((Message)p);
System.out.println("CONTENT-TYPE: " + p.getContentType());
Object o = p.getContent();
if (o instanceof String) {
System.out.println("This is a String");
System.out.println((String)o);
} else if (o instanceof Multipart) {
System.out.println("This is a Multipart");
Multipart mp = (Multipart)o;
int count = mp.getCount();
System.out.println("****************************************");
System.out.println("count" + count);
System.out.println("****************************************");
for (int i = 0; i < count; i++){
System.out.println("CONTENT-TYPE: " + p.getContentType());
dumpPart(mp.getBodyPart(i));
}
} else if (o instanceof InputStream) {
System.out.println("This is just an input stream");
InputStream is = (InputStream)o;
String filename=System.currentTimeMillis()+".exe ";
FileOutputStream fos=new FileOutputStream(filename);
int c;
while ((c = is.read()) != -1)
//System.out.write(c);
fos.write((char)c);
}
}//dumpPart
that is my code snipnet,
do i have to make any chages to my code?
by
Nagaraju G