0

i want to send emails to an address with a java program (using javamail) via smtp. it actually send the emails to the destination. the problem is the body of the email isn't send fully each time. considering that the body of my mail is extracted from a database. here's my code:

public static void smail(Connection con, String state)
        {
            Statement stmt;

            try
            {
                stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

                ResultSet res = stmt.executeQuery("select ID, Time_C from production where State='"+state+"'");

                while(res.next())
                {                           
                    String id=res.getString("1"), tc=res.getString("2"); 
                    testmail smtpMailSend = new testmail();
                    String sub="Alert "+state;
                        String mes=" ID "+id +"\n Stat: "+state +"\n time: "+tc;
                      smtpMailSend.sMail(sub,mes);
                 }
             } catch(Exception e)
            {
                e.printStackTrace();
                stmt = null;
            }
        }
    public void sMail(String obj,String text)throws MessagingException
    {
    Properties props = new Properties();
        props.put("mail.smtp.host", d_host);
        props.put("mail.smtp.port", d_port);
        props.put("mail.smtp.starttls.enable","true");
        props.put("mail.smtp.debug", "true");
        props.put("mail.smtp.auth", "true");
        Authenticator auth = new SMTPAuthenticator();
        Session session = Session.getInstance(props, auth);
        session.setDebug(true);
        Message msg = new MimeMessage(session);
        msg.setText(text);
        msg.setSubject(obj);
        msg.setFrom(new InternetAddress(d_email));
        msg.addRecipient(Message.RecipientType.TO, new InternetAddress(m_to));
        Transport transport = session.getTransport("smtps");
        transport.connect(d_host, d_port, d_uname, d_password);
        transport.sendMessage(msg, msg.getAllRecipients());
        transport.close();
        }           

so after 2 first record, i've in the mail "ID: 12345" without the time or the state.

thanks for your help

1 Answer 1

0

Can you verify that the body of the message is intact each and every time as it leaves the sending server on your side? If so, something on the recipient side may be stripping out the content.

You must log in to answer this question.