E8邮件代码
Posted 血月葬花魂
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了E8邮件代码相关的知识,希望对你有一定的参考价值。
if (rs1.next()) mailname = rs1.getString("email"); lastname = rs1.getString("lastname"); ArrayList filenames = new ArrayList(); ArrayList filecontents = new ArrayList(); String emailcontents = lastname + ":你好" + "\\r\\n" + "部门:" + depName + "已废弃,需要更换部门,请及时调整!"; String emailTitle = "机台所属部门已废弃"; SendRemindMail(mailname, emailTitle, emailcontents, filenames, filecontents);
邮件发送代码
private void SendRemindMail(String custEmail, String emailTitle, String emailContent, ArrayList filenames, ArrayList filecontents) new Thread(new WorkflowSendMailRunnable(custEmail, emailTitle, emailContent, filenames, filecontents)).start();
Oracle PLSQL通过SMTP发送E-MAIL邮件代码
登录到SMTPserver发送邮件,支持HTML
CREATE OR REPLACE PROCEDURE send_mail( p_recipient VARCHAR2, -- 邮件接收人 p_subject VARCHAR2, -- 邮件标题 p_message VARCHAR2 -- 邮件正文 ) IS --以下四个变量请依据实际邮件server进行赋值 v_mailhost VARCHAR2(30) := ‘smtp.163.com‘; --SMTPserver地址 v_user VARCHAR2(30) := ‘[email protected]‘; --登录SMTPserver的username v_pass VARCHAR2(20) := ‘System123‘; --登录SMTPserver的password v_sender VARCHAR2(50) := ‘[email protected]‘; --发送者邮箱。一般与 ps_user 相应 v_conn UTL_SMTP. connection ; --到邮件server的连接 v_msg varchar2(4000); --邮件内容 BEGIN v_conn := UTL_SMTP.open_connection(v_mailhost, 25); UTL_SMTP.ehlo(v_conn, v_mailhost); --是用 ehlo() 而不是 helo() 函数 --否则会报:ORA-29279: SMTP 永久性错误: 503 5.5.2 Send hello first. UTL_SMTP.command(v_conn, ‘AUTH LOGIN‘ ); -- smtpserver登录校验 UTL_SMTP.command(v_conn,UTL_RAW.cast_to_varchar2(UTL_ENCODE.base64_encode(UTL_RAW.cast_to_raw(v_user)))); UTL_SMTP.command(v_conn,UTL_RAW.cast_to_varchar2(UTL_ENCODE.base64_encode(UTL_RAW.cast_to_raw(v_pass)))); UTL_SMTP.mail(v_conn, v_sender); --设置发件人 UTL_SMTP.rcpt(v_conn, p_recipient); --设置收件人 -- 创建要发送的邮件内容 注意报头信息和邮件正文之间要空一行 v_msg := ‘Date:‘ || TO_CHAR(SYSDATE, ‘dd mon yy hh24:mi:ss‘ ) || UTL_TCP.CRLF || ‘From: ‘ || ‘<‘ || v_sender || ‘>‘ || UTL_TCP.CRLF || ‘To: ‘ || ‘<‘ || p_recipient || ‘>‘ || UTL_TCP.CRLF || ‘Subject: ‘ || p_subject || UTL_TCP.CRLF || ‘Content-Type:text/html;charset=GBK‘ || UTL_TCP.CRLF || UTL_TCP.CRLF -- 这前面是报头信息 || p_message; -- 这个是邮件正文 UTL_SMTP.open_data(v_conn); --打开流 UTL_SMTP.write_raw_data(v_conn, UTL_RAW.cast_to_raw(convert(v_msg,‘ZHS16GBK‘))); --这样写标题和内容都能用中文 UTL_SMTP.close_data(v_conn); --关闭流 UTL_SMTP.quit(v_conn); --关闭连接 EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.put_line(DBMS_UTILITY.format_error_stack); DBMS_OUTPUT.put_line(DBMS_UTILITY.format_call_stack); END send_mail;
以上是关于E8邮件代码的主要内容,如果未能解决你的问题,请参考以下文章