APEX_MAIL. ADD_ATTACHMENT does not

I use APEX_MAIL to send emails and I use ADD_ATTACHMENT to attach files stored by the browser of files as blobs in the tables. Sends the email with the text, but there is no attachment in the e-mail. Any ideas as to why? I have read several other forums with no. meet this.

APEX_MAIL. ADD_ATTACHMENT stopped working after the 4.2 update this archived discussion suggests that the error is a bug of apex 4.2 any since he moved not prior.

My code is below. This code sends an e-mail with NO attachment. Any help is appreciated.

DECLARE

l_id NUMBER;

BEGIN

l_id: = APEX_MAIL. SEND)

        p_to        => ' [email protected] ',

        p_from      => ' [email protected] ',

p_subj = > 'APEX_MAIL with attachment. "

p_body = > "Please see the attachment."

p_body_html = > ' review of < b > please < /b > the attachment ');

C1 (SELECT filename, blob_content, mime_type

from APEX_APPLICATION_FILES WHERE ID = 2568915681598084) LOOP

APEX_MAIL. ADD_ATTACHMENT)

p_mail_id = > l_id,

p_attachment = > c1.blob_content,

p_filename = > c1.filename,

p_mime_type = > c1.mime_type);

END LOOP;

COMMIT;

END;

I don't know why the APEX_MAIL. ADD_ATTACHMENT does not work, but I decided to just work around him. It could be a bug with 4.2.5 since PCHIU said 4.2.6 works. The following can be credited to Tim Hall-ORACLE-BASED and it works fine.

https://Oracle-base.com/articles/Misc/email-from-Oracle-plsq


Here is the procedure BLOB that must be uploaded to the database via SQLPLUS or any other method. This part can be copy pasted from here or the original source in the link provided above.

--

-Send an email with attachment of BLOB

--

CREATE or REPLACE PROCEDURE PA_SEND_BLOB_ATTACH (p_to IN VARCHAR2,

P_FROM IN VARCHAR2,

p_subject IN VARCHAR2,

p_text_msg IN VARCHAR2 DEFAULT NULL,

p_attach_name IN VARCHAR2 DEFAULT NULL,

p_attach_mime IN VARCHAR2 DEFAULT NULL,

p_attach_blob IN BLOB DEFAULT NULL,

p_smtp_host IN VARCHAR2,

p_smtp_port in DEFAULT NUMBER 25)

AS

l_mail_conn UTL_SMTP.connection;

l_boundary VARCHAR2 (50): = '-= * #abc1234321cba #* =';

l_step PLS_INTEGER: = 12000; -Make sure you define a multiple of 3 would not exceed the 24573

BEGIN

l_mail_conn: = UTL_SMTP.open_connection (p_smtp_host, p_smtp_port);

UTL_SMTP. HELO (l_mail_conn, p_smtp_host);

UTL_SMTP.mail (l_mail_conn, p_from);

UTL_SMTP. RCPT (l_mail_conn, p_to);

UTL_SMTP.open_data (l_mail_conn);

UTL_SMTP.write_data (l_mail_conn, ' Date: ' |) TO_CHAR (SYSDATE, ' ' DD-MON-YYYY HH24:MI:SS) | UTL_TCP. CRLF);

UTL_SMTP.write_data (l_mail_conn, ' from: ' | p_to |) UTL_TCP. CRLF);

UTL_SMTP.write_data (l_mail_conn, ' from: ' | p_from |) UTL_TCP. CRLF);

UTL_SMTP.write_data (l_mail_conn, ' subject: ' | p_subject |) UTL_TCP. CRLF);

UTL_SMTP.write_data (l_mail_conn, ' Reply-To: ' | p_from |) UTL_TCP. CRLF);

UTL_SMTP.write_data (l_mail_conn, "MIME-Version: 1.0 ' |") UTL_TCP. CRLF);

UTL_SMTP.write_data (l_mail_conn, ' Content-Type: multipart/mixed; limit = "" | ") l_boundary | '"' || UTL_TCP. CRLF. UTL_TCP. CRLF);

IF p_text_msg IS NOT NULL THEN

UTL_SMTP.write_data (l_mail_conn, '-' | l_boundary |) UTL_TCP. CRLF);

UTL_SMTP.write_data (l_mail_conn, ' Content-Type: text/plain; charset = "iso-8859-1" ' |) UTL_TCP. CRLF. UTL_TCP. CRLF);

UTL_SMTP.write_data (l_mail_conn, p_text_msg);

UTL_SMTP.write_data (l_mail_conn, UTL_TCP.crlf |) UTL_TCP. CRLF);

END IF;

IF p_attach_name IS NOT NULL THEN

UTL_SMTP.write_data (l_mail_conn, '-' | l_boundary |) UTL_TCP. CRLF);

UTL_SMTP.write_data (l_mail_conn, ' Content-Type: ' | p_attach_mime |) '; name =' ' | p_attach_name | '"' || UTL_TCP. CRLF);

UTL_SMTP.write_data (l_mail_conn, "Content-Transfer-Encoding: base64' |") UTL_TCP. CRLF);

UTL_SMTP.write_data (l_mail_conn, ' Content-Disposition: attachment; filename = "" | ") p_attach_name | '"' || UTL_TCP. CRLF. UTL_TCP. CRLF);

FOR i FROM 0... TRUNC ((DBMS_LOB. GetLength (p_attach_blob) - 1) / l_step) LOOP

UTL_SMTP.write_data (l_mail_conn, UTL_RAW.cast_to_varchar2 (UTL_ENCODE.base64_encode (DBMS_LOB.substr (p_attach_blob, l_step, I * l_step + 1)));)

END LOOP;

UTL_SMTP.write_data (l_mail_conn, UTL_TCP.crlf |) UTL_TCP. CRLF);

END IF;

UTL_SMTP.write_data (l_mail_conn, '-' | l_boundary |) '--' || UTL_TCP. CRLF);

UTL_SMTP.close_data (l_mail_conn);

UTL_SMTP. Quit (l_mail_conn);

END;

/

DISPLAY ERRORS;

The above procedure now allows you, run the following PL/SQL code:

DECLARE

l_blob BLOB;

l_filename VARCHAR2 (50);

l_mime VARCHAR2 (20);

BEGIN

Select ATTACH_FILENAME in the OFATTACH l_filename where WEIGHT = '12345';

Select ATTACH_MIMETYPE in the OFATTACH l_mime where WEIGHT = '12345';

Select ATTACH_DATA in the OFATTACH l_blob where WEIGHT = '12345';

() PA_SEND_BLOB_ATTACH

p_to => ' [email protected]',.

P_FROM => ' [email protected]',

p_subject-online 'Test Message',

p_text_msg-online "Please open the attachment BLOB."

p_attach_name-online l_filename,

p_attach_mime-online l_mime,

p_attach_blob-online l_blob,

p_smtp_host-online 'mail.test.com');

END;

/

Above, I select different BLOB attributes in the declared variables, and then call the procedure that we have imported before. You can run it directly from APEX in a PL/SQL procedure and you can even implement a loop that will allow you to join several files and send them in an e-mail. I didn't get that far, but I thought I'd post what I have so far. I also used my own table, as suggested which cleared up my problem with tables APEX is not not visible outside of the APEX. I hope this helps someone with their problem. I apologize if I explain evil.

Tags: Database

Similar Questions

  • Hosted Oracle Workspace Email does not?

    Hi team,


    Is a current maintenance work apex. Oracle.com the last 12 to 14 hours?


    Until yesterday, email to apex. Oracle.com went smoothly. Today morning, e-mail simple code start


    apex_mail. Send

    (p_to = > '[email protected]', )

             p_from           => ' [email protected] ',

    p_body = > 'Cool ',.

    p_body_html = > 'Cool ',.

    p_subj = > 'Cool '.

    );

    apex_mail.push_queue;

    end;


    does not through. Apex_mail_log shows no errors. Queue is empty.


    I don't know what happened to this code working until yesterday. Are there limits on sending e-mails that I saw in my application? However, it does not even for SQL workshop. Can someone try to send e-mail and see it please.


    joelkallman-Oracle Chubby Kiran Can you please check. Thank you.


    Kind regards

    Sunil Bhatia

    Hi Sunil,

    SHE looked at him.  There was a change of configuration of sendmail that caused this problem.  It is now fixed.

    Thanks again for reporting this.

    Joel

  • Process of e-mail does not work

    Hello

    I have the procedure in my application that needs to send emails, but it does not work. So, I tried to send a normal email to application using this block

    "DECLARE."
    l_body CLOB.
    BEGIN
    l_body: = ' thank you for your interest in the APEX_MAIL
    package.' | UTL_TCP. CRLF. UTL_TCP. CRLF;
    l_body: = l_body | ' Sincerely,' | UTL_TCP. CRLF;
    l_body: = l_body | "Dev APEX team ' | UTL_TCP. CRLF;
    () apex_mail. Send
    p_to = > 'my_email',-change to your email address
    P_FROM = > 'Another_email',-change for a real senders e-mail address
    p_body = > l_body,
    p_subj = > 'APEX_MAIL Package - message in plain text');
    END; »

    But it's also not working not, am I missing something? Knowing that I work in a local network.

    Thank you!

    Hi Debbie,

    You can check with your DBA if you have privileges to the UTL_SMTP and APEX_MAIL package.
    Configure your e-mail settings in the internal workspace > Instance settings

    -Divya

  • iPhone 7 more buttons outside does not

    I've had my iPhone 7 + for about 2 weeks now. Every once in awhile all buttons outside to stop, volume up/down, power, home. The home button will still record and push and give the sensation of taptic and touchID works. The phone itself still works and I can answer texts and which do not use notifications.

    The couple spent time he did, he came upon her in about 4-5 minutes, however it was about half an hour and still nothing. I want to restart my phone, but the switch does not work.

    Has anyone seen this issue or know how to fix?

    Thanks in advance.

    I just experienced the same problem on my iPhone 7, I think it's a bug in iOS, but I am using iOS 10.0.2. Power + button low Volume allowed me to turn it off then turn it back on... Apple please fix this bug!

  • App store, Safari and iTunes does not connect to the Internet after installing macOS Sierra

    App store, Safari and iTunes does not connect to the Internet after installing macOS Sierra

    After upgrade 'OS X El Capitan' to "macOS Sierra" window only empty "App store" and page "Safari" made its appearance, no error message shows. store "iTunes" and "Dictionary" does not connect too.

    But Google chrome works well.

    So have you tried the next steps in your original post that Safari does not work after installing macOS Sierra:

    (1) x OS: "Unable to connect" or "unable to connect to the App Store. An internet connection is required"- Apple Support

    2) Advanced the steps to correct the problems with the iTunes Store - Apple Support connection

  • Safari does not work after installing macOS Sierra

    Safari and apple store does not work after installing macOS Sierra

    Alas, my crystal ball is in the shop for cleaning, so you will need to provide more details on what "doesn't work" and above all error messages. First of all, let's start the App Store. Provide as much information as possible for those of us who do not sit on your shoulder.

  • My iPad Apple 3rd generation wifi + his cell phone does not work

    MY 3rd generation Apple iPad, wifi + cell

    model number MD408LL/a

    Serial number DM * VGL

    THE SOUND DOES NOT WORK

    < personal information under the direction of the host >

    All sounds, or simply notification and sounds apps (for example do music and videos app still have sound)? If notifications and apps you have notifications on mute: on the iPad side switch - Apple Support ? If the sounds in all applications which have tried for example soft-reset/reboot of the iPad, insert/remove the headphones?

  • After recent, iPhone, 6, update, Windows, Explorer, does not work, see, iPhone

    I installed the latest update required for my iphone ios 6 a few days ago, and now when I try to download pictures from my iphone to my PC (via USB connection), the PC does not see the iphone.   iTunes sees it yet, but windows Explorer does not work.  It seems that some setting has been broken through the update of ios.  A way to solve this problem?

    Restart the computer and the iPhone. Unlock the iPhone before connecting it to the computer. Any change?

    TT2

  • iPhone 7 more telephoto camera does not

    Is anyone having problems with iPhone 7 more telephoto does not activate. I'll go to the camera application and press the 2 x zoom feature, but it appears to be not to activate the camera of 56mm at the front. I cover the lens with my finger, the camera on the right side and the iPhone always displays an image despite me concealing one of the cameras teo. I can't activate the second camera. It seems to only be zooming digitally. I'll do this outside and he'll only digitally zoom when I hide the second lens.

    Im having this same problem. I heard from someone that he could not work until the next software update... but I have no idea and have not found anything in the online help. If someone else gets to know how.

  • Contact ID battery fast draining iPhone 5s does not

    5s fast drainage and Touch ID sinice 10.0.2 iOS iPhone battery update does not

    Restarted the iPhone since the update yet?

    1. Press and hold the sleep/wake button until the Red slider appears.
    2. Drag the slider to turn off your device completely off.
    3. Once the device turns off, press and hold the sleep/wake button again until you see the Apple logo.
  • Open the link behind Mail does not work

    Sierra using my link opened behind Mail does not work. The link opens on the top of the window.

    This option works for me in Sierra... is working for you with your previous version of the OS?

  • Update for Sierra and now my Apple music does not appear I have a subscription and I am unable to get my music on the cloud?

    Update for Sierra and now my Apple music does not appear I have a subscription and I am unable to get my music on the cloud?

    Hey there Scotchman2926,

    I understand that you are experiencing some problems with Apple music on Sierra. I have a few suggestions to help you solve this problem. First of all, if you are unable to access the iTunes Store as well as music from Apple, use the information in this article to help resolve this problem:

    If you cannot connect to the iTunes Store - Apple Support

    If this does not resolve the problem, you might try signing out of your Apple ID in iTunes and then connect again.

    Thanks to be come to the communities of Apple Support and let us know how it goes.

    See you soon.

  • iPhone 5 home button does not work after ios 10

    My 5 Iphone Home button does not work after update final IOS version of 10.

    The home button works on the first push to wake the phone but it will not open the phone the second button.

    I activated the assist button, which does not work either. But what I discover is if I open device for assistance then touch and lock screen click on the button home will work once to open the phone. If I open any app I can't close it unless I go through the same routine.

    You attempted to restart your phone?

    You can do so by holding the sleep/wake button and the Home button simultaneously until the Apple logo appears

  • New IMac does not, Apple does not change

    https://www.YouTube.com/watch?v=UdUY038FwCI

    I have this problem since I was the imac. I pointed out in 3 days. Apple does not change because I didn't buy that at its retailer. 3 months, still waiting.

    What should I do?

    Everyone pays even, but I get nothing (same lack offers as a freelancer). I think it's fair. What am I, I guess what to do?

    Run the Apple Hardware Test > Apple Hardware Test - Apple help

  • Why Safary does not load the content of pages?

    Why Safary does not load the content of pages? I mean, when I hover over the places where should be the content, he is always showing the "redirect to: [email protected]/" lower left. My Safari is 9.5 and worked fine until Safe Fimder Virus get inside my computer. Mozilla Firefox is a bit slower. If someone could give me an idea on how to deal with it, I would be happy.

    Sorry if my English is not good, I am a Brazilian who is still learning English

    Your English is very good!

    Redirects are usually due to adware or malware.

    Download the run MalwareBytes.

    It of free and takes only a minute or two. Which should remove all adware and malicious software on your Mac.

Maybe you are looking for

  • unpredictable font size

    If the display of the Web site in landscape, the text on the page is as specified in the css - 12px; but, when you view the same page in portrait mode, the text is HUMONGOUS and defies the CSS. I am currently using firefox 22, but has happened since

  • How to restore my files after resetting my computer?

    original title: how iget back my files after resetting my computer? I recently had to resett my computer after trying to go wireless, my broadband provider sent me a defective router and my laptop just crashed! I had to restore it back to factory set

  • No privileges for the user account

    Hey there, I have a strange problem and I'm not finding useful answers... I installed Windows 7 Pro on a box that is used as a file server, database server and the virtual machine host. Homegroup is disabled and password sharing is turned on. While I

  • I'm burning a playlist to a recordable CD, and it stops after about 50%

    I'm burning a playlist downloaded from cloud Amazon on a new recordable CD player. It is very well up to about 50% and then stops and I get an error message. The songs that have already burned are fine and I can play on a cd player, but it does not b

  • Installation of Microsoft Office Professional Plus 2013

    I have a code to program to buy Microsoft Office Professional Plus 2013 for my new laptop Acer Aspire V5, that uses the Windows 8 operating system. I entered the code to http://hup.microsoft.com/ and received the appropriate e-mail, but when I click