Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it L'avatar di morphy79
    Registrato dal
    Jun 2004
    Messaggi
    1,568

    [java] javamail invio testo

    Mi dite come fare per far accettare tutti i tipi di caratteri quando invio le mail utilizzando javamail ???
    Con questo codice il body mi viene messo come allegato nella mail perchè non gli piacciono alcuni caratteri...

    codice:
    public boolean sendMail(String to, String subject, String body){
    		boolean returnValue = false;
    		try{
    			Properties props = System.getProperties();
    			props.put("mail.smtp.host", smtpServer);
    			Session session = Session.getDefaultInstance(props, null);
    
    			// -- Create a new message --
    			Message msg = new MimeMessage(session);
    
    			// -- Set the FROM and TO fields --
    			msg.setFrom(new InternetAddress(from));
    			msg.setRecipients(Message.RecipientType.TO,
    			InternetAddress.parse(to, false));
    
    			// -- Set the subject and body text --
    			msg.setSubject(subject);
    			msg.setText(body);
    			
    			// -- Set some other header information --
    			msg.setHeader("X-Mailer", "LOTONtechEmail");
    			msg.setSentDate(new Date());
    			
    			// -- Send the message --
    			Transport.send(msg);
    			
    			//System.out.println("Message sent OK.");
    			returnValue = true;
    		}catch (Exception ex){
    			returnValue = false;
    		}
    		
    		return returnValue;
    		
    	}
    odio chi parla di politica..
    anzi vorrei fondare un partito contro tutto ciò

  2. #2
    Utente di HTML.it L'avatar di morphy79
    Registrato dal
    Jun 2004
    Messaggi
    1,568
    risolto con grande fatica...

    codice:
    String charset = "utf-8";
    msg.setContent(body, "text/plain; charset=" + charset);
    odio chi parla di politica..
    anzi vorrei fondare un partito contro tutto ciò

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.