gpt4 book ai didi

JavaMail POP3 邮件客户端错误

转载 作者:行者123 更新时间:2023-12-02 07:30:34 24 4
gpt4 key购买 nike

我正在开发一个 java 邮件客户端:

import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;

public class MailClient {
public static void main(String[] args) {
try {
Properties props = new Properties();
Session session;

URLName url = new URLName("pop3","pop.gmail.com",995,"","email@gmail.com","password");
session = Session.getInstance(props, null);
Store store = new POP3SSLStore(session,url);
store.connect();

Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);

Message message[] = folder.getMessages();

for (int i=0, n = message.length; i<n; i++) {
System.out.println(message[i].getSubject());
}
folder.close(false);
store.close();
}
catch (MessagingException e) {
System.out.println("Error: " + e);
}
}
}

发生的错误是这样的:

MailClient.java:13: error: cannot find symbol
Store store = new POP3SSLStore(session,url);
symbol: class POP3SSLStore
location: class MailClient
1 error

最佳答案

您缺少导入:

import com.sun.mail.pop3.POP3SSLStore;

之后应该可以编译

关于JavaMail POP3 邮件客户端错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12967278/

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