Tag: exchange server

如何从Java中的MS Exchange Server以编程方式获取电子邮件标头?

我无法访问电子邮件中的标题。 那一刻我只能获得ExtendedPropertyCollection对象,但我不知道如何使用它。 ItemEvent item = (ItemEvent) event; EmailMessage message = EmailMessage.bind(args.getSubscription().getService(), item.getItemId()); ExtendedPropertyCollection extendedProperties = ((ExtendedPropertyCollection) message.getExtendedProperties()); 更新: Java中的结果代码如下所示: PropertySet propertySet = new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.MimeContent); EmailMessage message = EmailMessage.bind(args.getSubscription().getService(), item.getItemId(), propertySet); String emailTextWithHeaders = new String(message.getMimeContent().getContent());

JavaMail连接问题

我正在尝试测试一个在线发现的简单程序,使用JavaMail发送电子邮件。 我试图使用工作电子邮件,但我收到错误“无法连接到SMTP主机:…”和“权限被拒绝:连接”。 我已经查看了有关此问题的其他post,包括: JavaMail Exchange身份validation 使用JSP发送电子邮件 JavaMail API到iMail – java.net.SocketException:权限被拒绝:连接 我想我已经解决了那些基本上是IPv4问题和身份validation的post的解决方案中提到的问题。 我是尝试使用JavaMail的新手,所以我想知道我是否在制作其他初学者错误。 还有其他我忽略的事情吗? 我是否有可能以这种方式访问​​服务器? 我使用的是通用名称而不是我公司的实际名称。 代码如下: public static void main(String[] args) { System.setProperty(“java.net.preferIPv4Stack” , “true”); String host=”mail.company.com”; final String user=”user@company.com”;//change accordingly final String password=”XXXXXXXX”;//change accordingly String to=”user@company.com”;//change accordingly //Get the session object Properties props = new Properties(); props.put(“mail.smtp.host”,host); props.put(“mail.smtp.auth”, “true”); Session session = Session.getDefaultInstance(props, new […]

使用Exchange Web服务Java API下载附件?

我正在编写一个Java应用程序来使用Exchange Web服务下载电子邮件。 我正在使用Microsoft的ewsjava API来执行此操作。 我可以获取电子邮件标题。 但是,我无法使用此API下载电子邮件附件。 以下是代码段。 FolderId folderId = new FolderId(WellKnownFolderName.Inbox, “mailbox@example.com”); findResults = service.findItems(folderId, view); for(Item item : findResults.getItems()) { if (item.getHasAttachments()) { AttachmentCollection attachmentsCol = item.getAttachments(); System.out.println(attachmentsCol.getCount()); // This is printing zero all the time. My message has one attachment. for (int i = 0; i < attachmentsCol.getCount(); i++) { FileAttachment attachment […]

JAVAMAIL:AUTH NTLM失败了

我尝试使用microsoft Exchange服务器在本地网络中发送带有java的电子邮件 有我的代码: import java.io.UnsupportedEncodingException; import java.util.Properties; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; public class Main { public static void main(String[] args) { final String username = “username@MyDomain.com”; final String password = “password”; Properties props = new Properties(); props.put(“mail.smtp.auth”, “true”); props.put(“mail.debug”, “true”); props.put(“mail.smtp.host”, “exchange_host.MyDomain.com”); props.put(“mail.smtp.port”, […]

Java邮件客户端到MS Exchange服务器

我们的MS交换服务器不使用Imap或pop3协议,我试图用Java编写客户端连接到交换服务器,我想我不能用Java Mail API做这个(如果我没错)。 我尝试使用端口110和143和25远程登录交换服务器地址,但没有运气。 任何人都可以建议,如果有现有的API来处理这种情况,任何建议都表示赞赏。

我可以在Java中对邮件服务器执行搜索吗?

我正在尝试使用Java搜索我的Gmail。 使用JavaMail,我可以通过消息搜索来执行消息,如下所示: Properties props = System.getProperties(); props.setProperty(“mail.store.protocol”, “imaps”); Session session = Session.getDefaultInstance(props, null); Store store = session.getStore(“imaps”); store.connect(“imap.gmail.com”, “myUsername”, “myPassword”); Folder inbox = store.getFolder(“Inbox”); inbox.open(Folder.READ_ONLY); SearchTerm term = new SearchTerm() { @Override public boolean match(Message mess) { try { return mess.getContent().toString().toLowerCase().indexOf(“boston”) != -1; } catch (IOException ex) { Logger.getLogger(JavaMailTest.class.getName()).log(Level.SEVERE, null, ex); } catch (MessagingException ex) […]

Exchange服务器不接受javax.mail API提供的用户名/密码

我有一个可爱的小Java客户端发送签名的电子邮件。 我们有一台Exchange服务器,需要用户名/密码validation才能发送邮件。 当我连接到Exchange服务器时,我收到此错误: avax.mail.AuthenticationFailedException: failed to connect at javax.mail.Service.connect(Service.java:322) at javax.mail.Service.connect(Service.java:172) 当我连接到其他服务器(Unix服务器)时,我没有问题。 以下是完整的调试跟踪。 我无法弄明白。 DEBUG: JavaMail version 1.4.2 DEBUG: successfully loaded resource: /META-INF/javamail.default.providers DEBUG: Tables of loaded providers DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SM} DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], } DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc] […]

使用JavaMail连接到IMAP获取“A1 NO LOGIN failed”exception

以下是我正在尝试连接的服务器的详细信息 mailbox_password = KexDa3P7hEtru mailbox_domain = mail.lenderlive.com mailbox_host= corp.lcl mailbox_username = SecondaryQC@lenderlive.com server_type = imap port = 143 我正在使用以下java代码连接到exchange: String domain = “mail.lenderlive.com”; String user= “SecondaryQC@lenderlive.com”; String password= “KexDa3P7hEtru”; String serverType = “imap”; Store store = null; Properties properties = System.getProperties(); Session session = Session.getDefaultInstance(properties); session.setDebug(true); store = session.getStore(serverType); store.connect(domain, user, password); 这是我得到的服务器跟踪: 2016-11-02 15:01:22,885 […]

使用MS Exchange的JavaMail:服务器和客户端均不支持身份validation机制

我几天来一直试图从Grails应用程序发送邮件但没有成功。 我在用着: grails 1.3.7 邮件1.0插件 spring-security-core 1.2.6插件 tomcat 7.0.23 Specifficaly我正在尝试使用部署在Tomcat服务器上的应用程序发送邮件,该端口25没有身份validation,没有SSL。 我已经尝试从部署了应用程序的VMWare虚拟机发送带有telnet的消息并且它已经通过了。 这是我发送邮件的课程: public boolean sendMessage(String to, String msgSubject, String msgText) { String host = “mail.mydomain.com”; String username = “myuser@mydomain.com”; // your authsmtp username String password = “mypassword” // your authsmtp password String from = “myuser@mydomain.com”; Properties props = System.getProperties(); props.put(“mail.smtp.host”, host); props.put(“mail.smtp.user”, username); props.put(“mail.smtp.password”, password); […]

Javamail NTLM身份validation失败

尝试在JavaMail中使用NTLM连接到Exchange服务器。 我可以连接到SMTP,但不能连接到IMAP。 我还可以使用相同的主机/用户名/密码,帐户类型=“IMAP”,端口143,ssl = false,身份validation= NTLM,域名=“”通过OS X Mail.app应用程序进行身份validation。 连接代码: import javax.mail.Session; import javax.mail.Transport; import javax.mail.Store; import java.util.Properties; public class NTLMTest { public static void main(String[] args) throws Exception { final String host = “example.com”; final String user = “bob”; final String password = “password”; final Properties properties = new Properties(); Session session = Session.getDefaultInstance(properties); session.setDebug(true); […]