Transport.send(消息)无效

时间:2018-02-09 05:08:23

标签: java email javamail

我正在使用波纹管代码发送自动邮件,它会发送邮件一段时间,它会卡在Transport.send(消息)行一段时间。所以我无法完全中继这个用于自动发送邮件的任何一个帮我解决问题。

           // Create a default MimeMessage object.
          ZipFolder.zipmyfolder(sResultReportFoldernew);
          //ZipFolder.zipmyfolder(resultscreenshotfilepath);


         Message message = new MimeMessage(session);

         // Set From: header field of the header.
         message.setFrom(new InternetAddress(from));

         // Set To: header field of the header.
         message.setRecipients(Message.RecipientType.TO,
            InternetAddress.parse(to));

         // Set Subject: header field
         String filepathtomail1 = sResultReportFoldernew+".zip";
         String baseurl33=urlsplit(baseurl1);
         //String baseurl33=baseurl1;
         sCurTime=ApplicationIndependent.getDateTime("dd-MMM-YYYY hh:mm:ss z");

         message.setSubject("Automation results for "+baseurl33+" "+sCurTime);

         // Create the message part
         BodyPart messageBodyPart = new MimeBodyPart();

         // Now set the actual message
         messageBodyPart.setText("please find the bellow attachment for the test excecution report");

         // Create a multipar message
         Multipart multipart = new MimeMultipart();

         // Set text message part
         multipart.addBodyPart(messageBodyPart);

         // Part two is attachment

         messageBodyPart = new MimeBodyPart();

         String filepathtomail2 =resultscreenshotfilepath+".zip";
         System.out.println("--------------------------beforee calling add attach");
         addAttachment(multipart,filepathtomail1,baseurl1);
     // Send the complete message parts
         message.setContent(multipart);

         // Send message
         Transport.send(message);

         System.out.println("Sent message successfully....");

0 个答案:

没有答案