gpt4 book ai didi

java - 无法解析导入javax.mail

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:30:44 27 4
gpt4 key购买 nike

<分区>

import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.SendFailedException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;

private void sendMail() throws MessagingException{

String host = "smtp.gmail.com";
String password = "abcde12345";
String from = "testing@gmail.com";
String toAddress = email;
String filename = Environment.getExternalStorageDirectory() + "/jam.jpg";

Properties properties = System.getProperties();
properties.put("mail.smtp.host", host);
properties.put("mail.smtps.auth", true);
properties.put("mail.smtp.starttls.enable", true);
Session session = Session.getInstance(properties, null);

MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.setRecipients(Message.RecipientType.TO, toAddress);
message.setSubject("Anti-Theft Attachment");

BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText(smsMessageString);

Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);

try{
Transport transport = session.getTransport("smtps");
transport.connect(host, from, password);
transport.sendMessage(message, message.getAllRecipients());
System.out.println("Mail Sent Successfully");
transport.close();
} catch (SendFailedException sfe){
System.out.println(sfe);
}
};

我正在开发一个应用程序,一旦手机被盗或丢失,该应用程序会自动向用户发送一封电子邮件,通知用户当前手机状态。但我在导入 javax.mail 时遇到问题“导入 javax.mail 无法解析”。我应该怎么办?谢谢...

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com