用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; } }
详细解决方案
邮件接口调用
热度:9 发布时间:2024-01-15 09:20:37.0
相关解决方案