2

我按照此链接生成 jar 文件。我将此添加到我的项目中。然后有一个简单的代码来发送邮件:

public void mailSend() {
        ExchangeService service = new ExchangeService();
        ExchangeCredentials credentials = new WebCredentials(
                "email", "$*pass!");
        service.setCredentials(credentials);

        String host = "host";
        try {
            service.setUrl(new java.net.URI("https://" + host
                    + "/EWS/Exchange.asmx"));

            service.setTraceEnabled(true);

            EmailMessage msg = new EmailMessage(service);
            msg.setSubject("Hello world!");
            msg.setBody(MessageBody
                    .getMessageBodyFromText("Sent using the EWS Managed API."));
            msg.getToRecipients().add("email");
            msg.send();
            Log.i("Msg","SEND   ");
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
}

问题是它显示 jar 文件没有源附件。因此我得到了错误no definition found for class ExchangeService。这应该是生成的 jar 文件的一部分。在导出为 jar 文件时,我确保单击了 src 文件夹。

4

0 回答 0