Email attachment in APEX

70 pts.
Tags:
hMail Server
Oracle Apex
PL/SQL
I was successful in sending bulk emails from an Apex application I developed to an email account on my hMail server but when the email reaches the account, all fields are delivered except the attachment. Below are the PL/SQL codes. Please, kindly help me check it through. Thanks DECLARE TYPE t_rec IS TABLE OF USERS%ROWTYPE INDEX BY PLS_INTEGER; v_ref_cur SYS_REFCURSOR; v_using VARCHAR2(10); v_ref_sql VARCHAR2(32767); v_rec T_REC; v_index NUMBER; v_id NUMBER; v_att_arr2 APEX_APPLICATION_GLOBAL.VC_ARR2; BEGIN v_using := '1'; v_ref_sql := 'SELECT * FROM ('||:P160002_IR_SQL||') WHERE ''1'' = :v_using'; OPEN v_ref_cur FOR v_ref_sql USING v_using; LOOP FETCH v_ref_cur BULK COLLECT INTO v_rec LIMIT 100000; IF v_rec.COUNT > 0 THEN FOR i IN 1..v_rec.COUNT LOOP BEGIN v_id := APEX_MAIL.SEND(p_to => v_rec(i).unofficial_email, p_from => 'admin@iyinmail.local', p_body => :P160000_MSG, p_body_html => :P160000_MSG, p_subj => :P160000_SUBJECT, p_cc => NULL, p_bcc => :P160002_CC, p_replyto => 'admin@neulogic.local'); v_att_arr2 := APEX_UTIL.STRING_TO_TABLE(:P160000_ATT); FOR v_index IN 1..v_att_arr2.count LOOP FOR c1 in (select filename, blob_content, mime_type from x_files where id = v_att_arr2(v_index)) loop APEX_MAIL.ADD_ATTACHMENT( p_mail_id => v_id, p_attachment => c1.blob_content, p_filename => c1.filename, p_mime_type => c1.mime_type); END LOOP c1; END LOOP v_index; EXCEPTION WHEN OTHERS THEN NULL; --raise_application_error(-20011, dbms_utility.format_error_backtrace); END; END LOOP; END IF; EXIT WHEN v_ref_cur%NOTFOUND; END LOOP; CLOSE v_ref_cur; END;

Software/Hardware used:
Oracle Application Express
ASKED: June 25, 2013  10:12 AM
UPDATED: June 25, 2013  2:15 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following