HOW to use the file/BLOB data temporary - email for multiple users... Please see code

Dear gurus
the code below works fine, he sends a good fixation to the first user, but to the 2nd user, it send blank (empty) file.
What I want, I have read the data from the source and enter the temporary BLOB and use the same data to send several users in the loop.


create or replace
PROCEDURE dba_ho.emailattacheulhr is
/ * LOB related operation varriables * /.
v_src_loc BFILE.
l_buffer RAW (54);
l_amount directory: = 54;
l_pos INTEGER: = 1;
l_blob BLOB: = EMPTY_BLOB;
l_blob_len INTEGER.
v_amount INTEGER.
/ * Related UTL_SMTP varriavles. */
v_connection_handle UTL_SMTP. CONNECTION;
v_from_email_address VARCHAR2 (200);
v_to_email_address VARCHAR2 (200);
v_cc VARCHAR2 (200);
v_smtp_host VARCHAR2 (50);
v_subject VARCHAR2 (500);
l_message VARCHAR2 (30000);
l_filename VARCHAR2 (4000);
CustNo number (8);
CNAME varchar2 (50);

cst slider is
Select a.EMAIL_ADDR, a.CARDHOLDER_NAME
Cust a
ORDER BY a.cust_no;

/ * This procedure of send_header is mentioned in the documentation * /.
PROCEDURE send_header (pi_name IN VARCHAR2, pi_header IN VARCHAR2) AS
BEGIN
UTL_SMTP. WRITE_DATA (v_connection_handle,
pi_name | ': ' || pi_header | UTL_TCP. CRLF);
END;

BEGIN
v_src_loc: = BFILENAME ('DIR_MMAIL', 'MAKPROM.pdf');
v_from_email_address: = '[email protected] ';
v_cc: = '[email protected] ';
v_smtp_host: = 'mailhost.mak.com ';
v_subject: = 'list of Promotion of Mak;
-l_blob BLOB: = EMPTY_BLOB;
/ * Prepare the LOB of attachment file. */
DBMS_LOB. OPEN (v_src_loc, DBMS_LOB. LOB_READONLY); -Read the file
DBMS_LOB. CREATETEMPORARY (l_blob, TRUE); -Create a temporary LOB to store the file.
v_amount: = DBMS_LOB. GETLENGTH (v_src_loc); -Amount to be stored.
DBMS_LOB. LOADFROMFILE (l_blob, v_src_loc, v_amount); -A temporary file in LOB loading
l_blob_len: = DBMS_LOB.getlength (l_blob);


Begin
CSE opened;

loop
extract the CSE in custno, v_to_email_address, cname;
When the output cst % notfound;

l_message: = 'Dear customer ' | UTL_TCP. CRLF;
l_message: = l_message | CNAME | UTL_TCP. CRLF;
l_message: = l_message | UTL_TCP. CRLF;
l_message: = l_message | "Thanks for choosing. Enclosed please find our current list of promotion for your review. '||
UTL_TCP. CRLF;
l_message: = l_message | UTL_TCP. CRLF;
l_message: = l_message | "Sincere friendships. UTL_TCP. CRLF;
l_message: = l_message | UTL_TCP. CRLF;
l_message: = l_message | UTL_TCP. CRLF;
l_message: = l_message | "To Mak' | UTL_TCP. CRLF;
l_message: = l_message | ' www.mak.com' | UTL_TCP. CRLF;

/ * Associated with coding UTL_SMTP. */
v_connection_handle: = UTL_SMTP. OPEN_CONNECTION (v_smtp_host, 25);
UTL_SMTP. HELO (v_connection_handle, v_smtp_host);
UTL_SMTP. MAIL (v_connection_handle, v_from_email_address);
UTL_SMTP. RCPT (v_connection_handle, v_to_email_address);
UTL_SMTP. RCPT (v_connection_handle, v_cc);

UTL_SMTP. OPEN_DATA (v_connection_handle);
send_header ("", v_from_email_address) ;--|| ("<>'");
send_header ("TO", v_to_email_address) ;--|| ("<>'");
send_header ('CC', v_cc);
send_header ('Subject', v_subject);

-MIME header.
UTL_SMTP. WRITE_DATA (v_connection_handle,
"MIME-Version: 1.0 ' |" UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle,
' Content-Type: multipart/mixed; ' || UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle,
"boundary =" ' | "'" Sample.SECBOUND' | '"' ||
UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle, UTL_TCP. CRLF);

-Body of the message
UTL_SMTP. WRITE_DATA (v_connection_handle,
'--' || "Sample.SECBOUND" | UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle,
' Content-Type: text/plain; "|| UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle,
'charset = US-ASCII' | UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle, UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle, l_message |) UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle, UTL_TCP. CRLF);

-Attachment of e-mail
UTL_SMTP. WRITE_DATA (v_connection_handle,
'--' || "Sample.SECBOUND" | UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle,
' Content-Type: application/octet-stream' |
UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle,
' Content-Disposition: attachment; ' || UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle,
"filename =" ' | "MakMail.pdf" | '"' || UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle,
' Content-Transfer-Encoding: base64' | UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle, UTL_TCP. CRLF);
/ * Write the BLOB into pieces * /.
While l_pos < l_blob_len LOOP
DBMS_LOB. READ (l_blob, l_amount, l_pos, l_buffer);
UTL_SMTP.write_raw_data (v_connection_handle,
UTL_ENCODE. Base64_encode (l_buffer));
UTL_SMTP. WRITE_DATA (v_connection_handle, UTL_TCP. CRLF);
l_buffer: = NULL;
l_pos: = l_pos + l_amount;
END LOOP;
UTL_SMTP. WRITE_DATA (v_connection_handle, UTL_TCP. CRLF);

-E-mail nearby
UTL_SMTP. WRITE_DATA (v_connection_handle,
'--' || "Sample.SECBOUND" | '--' || UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle,
UTL_TCP. CRLF. '.' || UTL_TCP. CRLF);
UTL_SMTP. CLOSE_DATA (v_connection_handle);
UTL_SMTP. Quit (v_connection_handle);
-DBMS_LOB. FREETEMPORARY (l_blob);
-DBMS_LOB. FileClose (v_src_loc);

End loop;


EXCEPTION
WHILE OTHERS THEN
UTL_SMTP. Quit (v_connection_handle);
DBMS_LOB. FREETEMPORARY (l_blob);
DBMS_LOB. FILECLOSE (V_SRC_LOC);
dbms_output.put_line (SQLERRM); -try to print the error message.
END;
DBMS_LOB. FREETEMPORARY (l_blob);
DBMS_LOB. FileClose (v_src_loc);
End;

-end of code

Help, please.

Concerning

S.Garewal

This is what happens when you copy a code without understanding.
Take a look at the code here

/* Writing the BLOB in chunks */
WHILE l_pos < l_blob_len LOOP
DBMS_LOB.READ(l_blob, l_amount, l_pos, l_buffer);
UTL_SMTP.write_raw_data(v_connection_handle,
UTL_ENCODE.BASE64_ENCODE(l_buffer));
UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
l_buffer := NULL;
l_pos := l_pos + l_amount;
END LOOP;

Discover the parameters of DBMS_LOB. READ.
For the first time it's good reading but your position and the quantity is not initialized when you loop and read again and is not read correctly.

Tags: Database

Similar Questions

  • How to duplicate the screen of Windows 8 start for multiple users

    I will implement separate user profiles for the grandkids on my PC of Windows 8 and want to start them all out with the same applications and settings.  I can do it all manually, but I would like to create one, and then copy the settings for others.  I know how to do this in previous versions, but so far have not seen splash screen settings at the usual place.

    Hi CraigLawrence,

    Thank you for choosing Windows 8 and join us on our community.

    Looks like you want to have the same start parameters of the screen for the user accounts. We will be happy to help you.

    You will be able to change the parameters of start screen under security settings for the family.

    I suggest you to follow these steps and check.

    a. press the Windows key + X , and then select Control Panel.

    b. Select the user accounts and family safety.

    c. Select family security and click on a user account.

    d. click on The Application of Restrictions and select the user will use the apps I leave.

    e. check the boxes for the apps you want to allow the user, and then click ok.

    Reference:

    You can go through the links for your reference.

    Set up parental controls

    http://Windows.Microsoft.com/en-us/Windows/set-up-family-safety#set-up-family-safety=Windows-8

    Using parental controls with the Windows store

    http://Windows.Microsoft.com/en-us/Windows-8/family-safety-settings-Windows-store

    Keep your family safe

    http://Windows.Microsoft.com/en-us/Windows-8/set-up-kids-accounts#1TC=T1

    Keep your family safe

    http://Windows.Microsoft.com/en-us/Windows-8/family-safety#1TC=T1

    It will be useful. For queries further feel free to come back.

  • How to use the node to call a library function to convert C++ source codes

    Hi all

    There are two dll name 'QMSL_WLAN_Transport.dll' and 'QCAMSL_MSVC10R.dll' and some codes c ++ to connect to the DUT. The two DLLs work together for communicaite with the DUT.

    I am confused as how to use the node to call a library function to load the 'QCAMSL_MSVC10R.dll' function as

    g_hResourceContext = QLIB_ConnectServer_UserDefinedTransport((HANDLE) USER_HANDLE,
    UserDefinedSend,
    UserDefinedReceive,
    UserDefinedFlushTxRx,
    true,
    true);
    

    It seems that 'UserDefinedReceive, UserDefinedSend, UserDefinedFlushTxRx' Processaddress?  And "UserDefinedReceive, UserDefinedSend, UserDefinedFlushTxRx"'s functions in 'QMSL_WLAN_Transport.dll '.

    UserDefinedReceive = (_UserDefinedReceive)GetProcAddress(hUDT,"UserDefinedReceive");
    UserDefinedSend = (_UserDefinedSend)GetProcAddress(hUDT,"UserDefinedSend");
    UserDefinedFlushTxRx = (_UserDefinedFlushTxRx)GetProcAddress(hUDT,"UserDefinedFlushTxRx");
    

    Attached DLLs and C++ code snippets.

    Need help.

    Thank you.

    These parameters are reminders - pointers to functions that are called by the DLL - and there is no way to duplicate this purely in LabVIEW. Search this forum for the word "recall" and you will find similar questions (for other DLLs). You will need to write your own DLL (in C, C++, etc.) that implements these functions and provides a way to transfer data to LabVIEW.

  • HP Envy 700-216: how to use the files in my System Recovery folder on my desktop?

    I had to do a recovery of the system, due to damaged or corrupted Windows files. I backed up my files on 9 DVDs. System Recovery has restored the files in a folder on my desktop, but how do I use them?

    I'm mainly interested in restoring my data to my Quicken 2010 and possibly my 2015 AutoCad.

    You are welcome.

    The only answer I have for not being able to find the files is that they can not have been backed up.  Otherwise, they should be in the folder.  I have to be honest.  I did several laps, but never made a backup of my files.  I always keep my personal data, backups of Quicken, photos, etc. on the external USB hard drives.  If the data are very important to me, I have it on at least two disks.

  • How to create the filter by date of request for access using database connectivity tool

    Hello

    I had started my project by reading the access data, using a UDL connection,

    but now I want to create a filter for access by using a query that would select two dates and get all the corresponding data, how to query using SQL Parmetrized?

    Best regards

    Note: I do not know the SQL language

    Hi salim_mjs,

    You must use the date format that I have used. It is independent of the format in your database. It should be "month/day/year".

    Mike

  • How to use the file that is saved in my new video project

    Ho I use adobe Prime Minister 12 with license elements, and when I download the video and edit (delete a scene of her) I save in my new video project in video format very strange *.prel after that when I try to download files of this new is that with the changes in the system can not download because not suport this format *.ples how do I make changes to the format of the new file that is saved in my new video project?

    Thanks in advance

    stefang

    Your work begins in a project file first items 12/12.1 with the file extension PREL. You can change the content of your Timeline and save the project file in a project file if you do not have ready to export the file to a format for playback.

    When you are ready to export your content published or not fake chronology, you go to the section of publication + part of the open project where you make your choice of export-

    a. file saved on the hard disk of the computer (with various choice of video and audio compressions and file extensions)

    b. burn to DVD, AVCHD or Blu - ray disc

    What do you do?

    a. export your Timeline to file or burn it to a disc?

    OT

    b. export selectively some of the content rather than the entire contents of the timeline timeline?

    For 'a', see section publication + share.

    For 'b '.

    In the editing area of the program, you set the gray tabs on the work area bar to cover the area to export.

    and

    When you get to publish + Share/computer/and your choice, make sure that the choice has an option for 'Hand work area Bar Only' and have a check mark next to this option.

    The screenshot was made with a version earlier than 11, but still applies to the notion of positioning of the grey tabs and share work area Bar only in the export options.

    Please review and consider. For any question or need clarification, please ask.

    Thank you.

    RTA

  • How to use the files from old computer to new iTunes

    I have been using an external hard drive to store and access my media files to iTunes via iTunes on another computer.   I just got a new computer and want to use this hard drive and files of music via iTunes on it.  What is the best way to do this and what are the steps to begin to play the files from the hard drive on the new iTunes?

    I have changed the preferences of the media folder in iTunes without result and sought media when iTunes opens, also without result.   Thank you!!!

    Media preferences are not what you think. Change said iTunes simply to memorize new media at this location. This is the file iTunes Library.itl tells iTunes where your media. If you use the same external drive (and these are the two Macs) copy the old iTunes folder form computer to the same location on the new computer and it will start with the old library.

  • How to use the file transfer Wizard

    I have and old Dell XP and I am go buy

    new Dell with Windows 7.  I'm going to

    disconnect the old computer and with some help

    Setup new computer using Dell Windows 7.

    I want to save, copy and install My Documents,

    My computer, email, and Favorites in new

    computer.  I tried the file transfer Wizard and

    the choice of external hardware is a floppy disk.

    I would like to record information about a cd, if

    possible, and when I get the new computer installation

    that's when I purchase.  I'm not

    technical savy.  Could someone please help.

    Thank you. Judy

    The Complete Guide to Windows Easy Transfer - video

    Carey Frisch

  • How to use the aggregate with Date function

    Hi all

    I have a Group date is it possible of Max and Min to date.

    I tried like this but its out errored <? MIN (current - group () / CREATION_DATE)? >.

    I also tried this, but it does not work
    <? xdoxslt:minimum (CREATION_DATE)? >

    Is it possible to use the function of aggregation with date values.

    Thanks and greetings
    Srikkanth

    You can use
    Ensure that the "date" is in canonical format

  • Flex 3: how to use the trace print data in the console

    Hello

    I heard that we can use trace to print data on the console in Flex Builder 3. But when I try, it's of no luck.

    Below is a simple program, in which I was out of luck.


    public function callMe (): void
    {
    trace ("AAA");

    }

    < mx:Button id = 'Save' name = 'Save' label = "Save" height = "23" click = "callMe ()" / >

    Here in the porogram above, after you have clicked on the button, I can't see 'AAA' related inside my Flex Builder.

    Any help?

    Thank you.

    Hi Kiran

    Made a breakpoint to the line of trace and debug the application you can find the message u typed in the console... trace works only in debug mode... not in development mode...

    Good day

    Thank you

    RAM

  • Having a hard time figuring out how to use the spot AF in my A65V I AM setting, please help!

    Whenever I try to select 'spot', the camera seems to automatically decide I want to concentrate on the spot is in the Center... How do you choose a different location? And also, you are able to change places while taking photos, or only you will need to return to the AF menu change back again?

    Thank you!!

    ~ guada

    Hi guadilus,

    Welcome to the community of Sony!

    If you set the camera to the place, the camera uses the area located exclusively in the central region.

    Use Local which allows you to select the field for which you want to activate the focus among 15 AF areas with the control key.

    Press the AF button to display the configuration screen and select the
    area.

    If my post answered your question, please mark it as "accept as a Solution.

    Thank you

    Zander

  • How to divide the request to assign a role to multiple users in several.

    Hello

    While we are assigning a role to multiple users OIM11g at the same time, demand has cut several queries to get approved by the Manager of beneficiaries. Please let us know ways to apply the composite to divide the application.

    Why two separate approval process? Instead of two only have a license deal with assignment of dynamic loop based Manager of beneficiary to the owner of the role, and attach it to the level of the operation and you should be good (with auto level template and request approval).
    The child requests are generated only at the level of the operation and NOT to any two previous levels. It is the engine of the application for you.

    -BB

  • How to find the broken blob data

    Hello

    I am using oracle 10G express edition and Oracle Apex 4.1 front-end, have created a table with structure below.

    > > CREATE TABLE 'HR_EMPLOYEE_DETAILS '.
    > > ('ID' NUMBER ENABLE NOT NULL,)
    > > 'HR_ID' ENABLE NUMBER NOT NULL,
    > > 'PHOTO_BLOB' BLOB,
    > > "MIME_TYPE" VARCHAR2 (64)
    (> >)


    I wrote a program sqlloader to load all the images in the table above, there are a few rows of data where the photos have not get uploaded, which shows the user but photo id is empty, how to identify such lines. Please suggest me

    Thank you
    Sudhir

    Your photo_blob column can have NULL values, in this case you can find them with something like:

    select id
      from hr_employee_details
     where photo_blob is null
    

    Or the photo_blob was filled with a LOB Locator is valid but contains no data. These cases can be found with something like:

    select id
      from hr_employee_details
     where dbms_lob.getlength(photo_blob) = 0
    

    Or you could have a case where some of the bytes actually enter the blob, but not all resulting in an invalid image. Who is going to be more difficult, try so the other two cases first ;-)

  • Hey, how to use the files as in Firefox for Android?

    Hey all. Since the add-on of Ghostery for Firefox Beta for android (36) has not worked, I contacted Ghostery customer service, and they responded with a beta version of the Ghostery add-on to see if it would work. There is a file as... I was wondering, how can I use it in Firefox for android? To make use of this add-on? Thank you!

    Hi Ererer

    I have never installed an add-on third party directly to the Android operating system (only on the desktop). If you find the as in your folder Android downloads or via the Android file manager if it is in a different directory, try tapping on it and see if it will open in Firefox for Android and settle. Don't know if it will work because this cannot carry on Android and I do not see in our documentatino: https://support.mozilla.org/en-US/kb/find-and-install-add-ons-firefox-android

    Please let me know if the above works.

    See you soon!

    ... Roland

  • How to remove the files / folders that require permission for administrators

    under C:/windows/temp is several files that I want to remove but when I try, they report that I need permission for administrators

    You must log in as an administrator instead of as a user on the Windows log in screen that appears when the operating system starts.

    Or you can go to start > switch user and then log in as admin.

Maybe you are looking for

  • There is no indication in the authors section

    I have the version 12.4 of the ITunes software and run it on a pc win10. My books appear in "audio books", but the "books" tab and the "authors" tab have nothing in them. All I see is a message telling me books appear there and a link to the iTunes s

  • Re: Satellite M45-S169 - need driver for Ethernet controller

    It has always been used with wireless, but not go now. Got the main due virus reformat and reinstall XP Professional. Everything's fine, everything works, but found a yellow flag in device manager for the ethernet controller. Have tried all the drive

  • battery dose not last

    battery dose not last

  • Satellite A200-1GH - asking of BIOS password

    The start of my laptop is blocked by BIOS password, even though I know exactly that the password was not established. It is a known issue with some Toshiba computers laptops listed here http://www.csd.toshiba.com/cgi-bin/tais/support/jsp/bulletin.jsp

  • Cannot set the contrast etc. in Windows Media Player 11...

    During playback of a DVD in WMP 11, I can't adjust contrast/brightness settings. The cursor jumps just to the Center. I use XP and Nvidia GeForce 210. Does anyone have a solution to this problem? Thank you very much...