MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("xyz@example.com"));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress("abcd@example.com"));
在unhandled exception type MessagingException
。
答案 0 :(得分:1)
你必须有可能解决它。
在代码中添加try-catch-block:
尝试{ MimeMessage msg = new MimeMessage(session); msg.setFrom(new InternetAddress(“xyz@example.com”)); msg.addRecipient(Message.RecipientType.TO,new InternetAddress(“abcd@example.com”));
} catch(MessagingException me){ // 做一点事 }
将throws MessagingException
添加到方法签名中:
public void mymethod throws MessagingException { MimeMessage msg = new MimeMessage(session); msg.setFrom(new InternetAddress(“xyz@example.com”)); msg.addRecipient(Message.RecipientType.TO,new InternetAddress(“abcd@example.com”)); }