Ok,sono sempre io con il mio programma di ricezione e-mail:tongue:
So che è molto stucchevole, ma sono costretto a postare quasi tutto il codice se qualcuno gli dà un'occhiata veloce e mi dice cosa sembra che non sia corretto...thks
codice:
public MailReader(Message mess) {
JPanel pannello;
initComponents();
this.setSize(600, 600);
try{
if (mess.getContent().equals("text/plain"))//Messaggio"semplice"
{
JTextArea testo = new JTextArea();
testo.setText(mess.getContent().toString());
pannello.add(testo);
}
if(mess.getContent().equals("multipart/*")) //MessaggioMultipart
{
spezza(mess); //definito in seguito
}
if(mess.getContent().equals("text/html"))
{
String content = (String) mess.getContent();
JEditorPane text = new JEditorPane();
text.setContentType("text/html");
text.setText(content);
text.setEditable(false);
pannello.add(text);
}
}
catch(Exception e){....;}
}
public void spezza(Message mess){
try{
Multipart parts = (Multipart) mess.getContent();
for(int i=0;i<parts.getCount();i++)
{
MimeBodyPart mbp = (MimeBodyPart) parts.getBodyPart(i);
if(mbp.isMimeType("text/html"))
{
String content = (String) mess.getContent();
JEditorPane text = new JEditorPane();
text.setContentType("text/html");
text.setText(content);
text.setEditable(false);
pannello.add(text);
}
else if(mbp.isMimeType("image/gif")
||mbp.isMimeType("image/jpeg"))
{
InputStream is = mbp.getInputStream();
int a = is.available();
byte[] b = new byte[a];
while(a > 0)
{
is.read(b);
a = is.available();
}
ImageIcon imm = new ImageIcon(b);
pannello.add(new JLabel(imm));
}
else if(mbp.isMimeType("text/plain"))
{
JTextArea testo = new JTextArea();
testo.append(mbp.getContent().toString());
pannello.add(testo);
}
}
}
catch(Exception e){....}
1)non ho problemi con messaggi SOLO text/plain
2)Non visualizzo messaggi text/html
3)Ho problemi con i messaggi Multipart in particolare riesco a visualizzare le immagini, ma se c'è del testo dopo l'immagine non lo vedo, e ancora se ci sono parti in html non riesco a visualizzarle
Help,Help,Help
Ogni consiglio è beneaccetto, altrimenti rischio di piantarmi e mollare tutto!