邮件接口调用

来源:互联网 发布:netflix 获奖算法 编辑:程序博客网 时间:2024/05/24 06:15
用axis2本地生成文件后调用就行,xmlbeans和abd都可以import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.tempuri.SendMailCDocument;import org.tempuri.SendMailCResponseDocument;import java.rmi.RemoteException;/** * @Author: zhangshulong * @Description: * @Date: Created in 17:25  2016/11/24 */public class EmailUtil {    private static final Logger LOGGER = LoggerFactory.getLogger(EmailUtil.class);    /**     *     * @param address 邮箱地址     * @param title 邮件主题     * @param content 邮件内容     * @param nickName 发件人     * @return     */    public static String sendEmail(String address, String title, String content, String nickName) {        com.opple.sendmail.ServiceStub stub = null;        SendMailCDocument sendMailCDocument = null;        SendMailCDocument.SendMailC sendMailC = null;        String xmlStr = null;        String aa = null;        String result = null;        String msg = null;        try {            sendMailCDocument = SendMailCDocument.Factory.newInstance();            sendMailC = sendMailCDocument.addNewSendMailC();            sendMailC.setMTo(address);            sendMailC.setMSubJect(title);            sendMailC.setMBoday(content);            sendMailC.setMSysType(nickName);            stub = new com.opple.sendmail.ServiceStub();            SendMailCResponseDocument sendMailCResponseDocument = stub.sendMailC(sendMailCDocument);            xmlStr = sendMailCResponseDocument.xmlText();            aa = xmlStr.split("<SendMailCResult>")[1];            msg = aa.split("</SendMailCResult>")[0];            if ("pass".equals(msg)) {                result = "发送成功";            } else {                result = "发送失败";            }        } catch (RemoteException e) {            LOGGER.error("e", e);            result = "发送失败";        } catch (Exception e) {            LOGGER.error("e", e);            result = "发送失败";        }        return result;    }}
0 0
原创粉丝点击