如何使用JavaMail获取HTML格式以处理多封电子邮件

如何使用JavaMail获取HTML格式以处理多封电子邮件,java,html,gmail,jakarta-mail,Java,Html,Gmail,Jakarta Mail,我正在尝试发送多封使用HTML格式的电子邮件,但只有第一封电子邮件以HTML格式发送,其余的以纯文本格式发送 有人知道问题出在哪里吗 以下是我发送多封电子邮件的代码: public static int sendmail(int ind)抛出AddressException、MessaginException、InterruptedException、IOException{ mailServerProperties=System.getProperties(); mailServerPrope

我正在尝试发送多封使用HTML格式的电子邮件,但只有第一封电子邮件以HTML格式发送,其余的以纯文本格式发送

有人知道问题出在哪里吗

以下是我发送多封电子邮件的代码:

public static int sendmail(int ind)抛出AddressException、MessaginException、InterruptedException、IOException{
mailServerProperties=System.getProperties();
mailServerProperties.put(“mail.smtp.port”,“587”);
mailServerProperties.put(“mail.smtp.auth”、“true”);
mailServerProperties.put(“mail.smtp.starttls.enable”,“true”);
getMailSession=Session.getDefaultInstance(mailServerProperties,null);
GenerateEmailMessage=新的MIMessage(getMailSession);
GenerateEmailMessage.setSubject(“问候”);
传输=getMailSession.getTransport(“smtp”);
transport.connect(“smtp.gmail.com”、电子邮件、密码);
罪犯;
for(inti=ind;i
测试。

测试人员”; setContent(emailBody,“text/html;charset=utf-8”); generateMailMessage.setSubject(“问候语”+i); 试一试{ transport.sendMessage(GenerateEmailMessage,GenerateEmailMessage.getAllRecipients()); 系统输出打印LN(i); }捕获(异常SMTPSendFailedException){ 系统输出打印项次(“编号”+i+“失败”); ind=i; 打破 } ind=i; } System.out.println(“四舍五入完成”); transport.close(); 返回ind; }

编辑您的问题,并在问题中包含代码。随着时间的推移,外部链接往往会消失,这会使你的问题对未来的读者毫无用处。这说明了什么?此外,您还需要编辑您的问题,并在问题中包含代码。随着时间的推移,外部链接往往会消失,这会使你的问题对未来的读者毫无用处。这说明了什么?而且,你也会想。