How can I email using UTL_SMTP with a csv file as an attachment?

Dear All,
It would be great if someone could help me. I am trying to use UTL_SMTP to email with a csv file as attachment. I do get an email with a message but no attachment arrives with it.
In fact the code used for attaching the csv file gets appended in the message body in the email.
CREATE OR REPLACE PROCEDURE test_mail
AS
SENDER constant VARCHAR2(80) := '[email protected]';
MAILHOST constant VARCHAR2(80) := 'mailhost.xxxx.ac.uk';
mail_conn utl_smtp.connection;
lv_rcpt VARCHAR2(80);
lv_mesg VARCHAR2(9900);
lv_subject VARCHAR2(80) := 'First Test Mail';
lv_brk VARCHAR2(2) := CHR(13)||CHR(10);
BEGIN
mail_conn := utl_smtp.open_connection(mailhost, 25) ;
utl_smtp.helo(mail_conn, MAILHOST) ;
dbms_output.put_line('Sending Email to : ' ||lv_brk||'Suhas Mitra' ) ;
lv_mesg := 'Date: '||TO_CHAR(sysdate,'dd Mon yy hh24:mi:ss')||lv_brk||
'From: <'||SENDER||'>'||lv_brk||
'Subject: '||lv_subject||lv_brk||
'To: '||'[email protected]'||lv_brk||
'MIME-Version: 1.0'||lv_brk||
'Content-type:text/html;charset=iso-8859-1'||lv_brk||
' boundary="-----SECBOUND"'||
''||lv_brk||
'-------SECBOUND'||
'Some Message'
          || lv_brk ||
'-------SECBOUND'||
          'Content-Type: text/plain;'|| lv_brk ||
          ' name="xxxx.csv"'|| lv_brk ||
          'Content-Transfer_Encoding: 8bit'|| lv_brk ||
          'Content-Disposition: attachment;'|| lv_brk ||
          ' filename="xxxx.csv"'|| lv_brk ||
          lv_brk ||
'CSV,file,attachement'|| lv_brk ||     -- Content of attachment
lv_brk||
'-------SECBOUND' ;
dbms_output.put_line('lv_mesg : ' || lv_mesg) ;
utl_smtp.mail(mail_conn, SENDER) ;
lv_rcpt := '[email protected]';
utl_smtp.rcpt(mail_conn, lv_rcpt) ;
utl_smtp.data(mail_conn, lv_mesg) ;
utl_smtp.quit(mail_conn);
EXCEPTION
WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
NULL ;
WHEN OTHERS THEN
dbms_output.put_line('Error Code : ' || SQLCODE) ;
dbms_output.put_line('Error Message : ' || SQLERRM) ;
utl_smtp.quit(mail_conn) ;
END;

LKBrwn_DBA wrote:
Use UTL_MAIL instead.That package is an utter disappointment - and an excellent example IMO of how not to design an application programming interface. Even the source code is shoddy.. I mean, having to resort to a GOTO statement....!!?? The person(s) who wrote that package are sorely lacking in even the most basic of programming skills if structured programming is ignored and a spaghetti command used instead.
No wonder the public interface of that code is equally shabby and thoughtless... The mail demo code posted by Oracle was better written than this "+package+" they now have bundled as the official Mail API.
I dunno.. if I was in product management there would have been hell to pay over pushing cr@p like that to customers.

Similar Messages

  • How can I email a photo in jpeg so it arrives as attachment to an email please

    How can I email a photo in jpeg so it arrives as attachment to an email please

    I use Safari email
    There is no Safari email. Do you mean you use a Web Based email service like Yahoo or Gmail and access it via Safari?
    sent the photo from iPhoto by following on screen instructions under 'share' in iPhoto
    Iphoto sends HTML emails so that will never send as an attachment.
    Regards
    TD

  • How can we export table data to a CSV file??

    Hi,
    I have the following requirement. Initially business agreed upon, exporting the table data to Excel file. But now, they would like to export the table data to a CSV file, which is not being supported by af:exportCollectionActionListener component.
    Because, when i opened the exported CSV file, i can see the exported data sorrounded with HTML tags. Hence the issue.
    Does someone has any solution for this ... Like, how can we export the table data to csv format. And it should work similar to exporting the data to excel sheet.
    For youre reference here is the code which i have used to export the table data..
    ><f:facet name="menus">
    ><af:menu text="Menu" id="m1">
    ><af:commandMenuItem text="Print" id="cmi1">
    ><af:exportCollectionActionListener exportedId="t1"
    >title="CommunicationDistributionList"
    >filename="CommunicationDistributionList"
    >type="excelHTML"/> ---- I tried with removing value for this attribute. With no value, it did not worked at all.
    ></af:commandMenuItem>
    ></af:menu>
    ></f:facet>
    Thanks & Regards,
    Kiran Konjeti

    Hi Alex,
    I have already visited that POST and it works only in 10g. Not in 11g.
    I got the solution for this. The solution is :
    Use the following code in jsff
    ==================
    <af:commandButton text="Export Data" id="ctb1">><af:fileDownloadActionListener contentType="text/csv; charset=utf-8"
    >filename="test.csv"
    >method="#{pageFlowScope.pageFlowScopeDemoAppMB.test}"/>
    ></af:commandButton>
    OR
    <af:commandButton text="Export Data" id="ctb1">><af:fileDownloadActionListener contentType="application/vnd.ms-excel; charset=utf-8"
    >filename="test.csv"
    >method="#{pageFlowScope.pageFlowScopeDemoAppMB.test}"/>
    ></af:commandButton>
    And place this code in ManagedBean
    ======================
    > public void test(FacesContext facesContext, OutputStream outputStream) throws IOException {
    > DCBindingContainer dcBindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    >DCIteratorBinding itrBinding = (DCIteratorBinding)dcBindings.get("fetchDataIterator");
    >tableRows = itrBinding.getAllRowsInRange();
    preparaing column headers
    >PrintWriter out = new PrintWriter(outputStream);
    >out.print(" ID");
    >out.print(",");
    >out.print("Name");
    >out.print(",");
    >out.print("Designation");
    >out.print(",");
    >out.print("Salary");
    >out.println();
    preparing column data
    > for(Row row : tableRows){
    >DCDataRow dataRow = (DCDataRow)row;
    > DataLoaderDTO dto = (DataLoaderDTO)dataRow.getDataProvider();
    >out.print(dto.getId());
    >out.print(",");
    >out.print(dto.getName());
    >out.print(",");
    >out.print(dto.getDesgntn());
    >out.print(",");
    >out.print(dto.getSalary());
    >out.println();
    >}
    >out.flush();
    >out.close();
    > }
    And do the following settings(*OPTIONAL*) for your browser - Only in case, if the file is being blocked by IE
    ==================================================================
    http://ais-ss.usc.edu/helpdoc/main/browser/bris004b.html
    This resolves implementation of exporting table data to CSV file in 11g.
    Thanks & Regards,
    Kiran Konjeti

  • How can I fix this problem with exporting Pages files?

    Hello,
    I'm having problems with exporting Pages files to Word or PDF (I haven't tried the other formats). Whenever I try to export the Page file, I get one message like this: "The document "XXXXXXX" could not be exported as "YYYYYYY". This problem started after the last Pages update, before that it was working fine. I restarted the computer, updated the OS, but the problem hasn't been solved.
    Does anyone know how to fix this problem?
    Thank you in advance!
    Best regards,
    Filipe

    Computers are made of parts made by humans and assembled by humans of materials that are not perfect.
    For example, a display cable that was accidentally pinched during assembly would pass quality control testing with flying colors and would not fail until the lid had been opened and closed several times.
    Likewise a display might not fail until powered on and off a few hundred times.

  • How can i get the column names in CSV file.

    Hi,
    After execution of infospoke i can not see the column names in that file.How can i get column of respective infoprovider?
    Thanks,
    Gananadha Lenka

    Hello Gana,
    Actually while exporting the data using Info Spoke, we have the possibility to modify the data that we send. This is possible using transformations.
    In your Info Spoke, you have a tab called Transformations.
    Here you need to create an implementation and then use BADi to populate data.
    Check if you can write a start routine sort of thing here and insert a new record into the internal table by hardcoding with your field headings.
    Let me know if you dont know how to create transformations.
    Kris...

  • How can I best use iCloud with another cloud based server

    Here is what I want to accomplish.  I have switched ISP's and wish to have all my email based in the cloud, so another switch of ISP is not so painful.  I have 2 accounts I monitor, iCloud for personal use, and another server for my website for business use.  I want to simply look at one mail box, that is iCloud that contains all email I route ... so, forward to the business server to Icloud and read iCloud from my mac, web browse, or ipad/cellphone.  So far OK.  The fly in the ointment is that I want to send emails with either my personal or business address from my mac or wherever, and can see no way to have both addresses available for sending, just the icloud based ones.
    Advice is wanted and appreciated.
    Thanks, Dan

    You can use different accounts for each of your devices, but why?  Then they couldn't sync with each other (and the icloud account they are associated with).
    But each device can only be associated with one icloud account, you can't have each connect to both accounts.  It seems you are trying to gain additional storage by using a second account.  To have both devices connecting to the same data and use more storage, you'll have to buy more.

  • How can I convert a PDF with a XFA file format

    I have an application that reader will not send, and it will not let me convert it to word or any other format.  I keep getting an error message that forms with an XFA format are not compatible. 

    Convert how: using Acrobat, or the ExportPDF service?

  • How can I reconnect my songs with actual media files

    After re-importing my 25,000 songs to Media folderthey show up as 'missing' [!] in iTunes browser. The files are there, but the browser can't 'find' them. I realize I could do this manually but with the size of my library that is a no go.
    I've tried to use Song Sergeant but it refuses to work "with MY system", as their support person told me!!
    Thanks

    Transfer your purchases before syncing:
    iTunes menu > Devices > Tansfer Purchases
    You won't lose any songs (and nothing will get loose in your phone)

  • How can I lodge a complaint with Apple about quality of products?

    I am about to purchase my fifth or sixth charger for my 13' macbook... of this last year and a half!! I am so unbelievably frustrated with the quality of my charger and the fact that these have to be replaced so often for products that, in just a few months, will stop working. How can I get in touch with Apple to file a complaint of this nature? None of the numbers listed on the contact website correspond with the nature of my complaint.

    lehath9, I don't know if this is the issue you're referring to, but I, too, am terribly frustrated by the amount of money I've spent on genuine Apple chargers in the last 18-24 months. 
    I believe the quality of the chargers has declined significantly and have had to replace, several times over, the chargers that came with my 2nd generation iPad, my iPhone 4S and the latest iPod touch.  The cables/wires are breaking and fraying.  
    I thought perhaps I was being too rough on my cables somehow the first couple times that it happened, but I know that's not the case now.  For comparison, the cables that came with my first two iPod classics and my first Nano are fine. I also took an informal survey via Facebook to see if others have noticed the same issue and got about 20 affirmative responses, all of which stated the problems started with chargers sold in the last 18 months. 
    I've purchased four replacements in the last six months and the third of those 4 is now broken, exactly as the previous 2 replacements and exactly like the three before those.  The rubber/plastic casing for the wires pulls away from the non-USB part of the charger (the end that goes into your ipad/iPhone/iPod).  Once it pulls away the wires are no longer supported and they start to hang at an odd angle (no matter how careful you are plugging, unplugging and positioning the charger in the device) causing them to break and of course preventing a charge from reaching the device. 

  • Using ExeShield with a Director File

    I developed a Director movie and need to publish it on a CD. I saw a tutorial from the ExeShield web site and it looks great and makes me able to add a serial number to it. Now I need to know if it is possible to use it with a Director file. Do I export the movie as a .exe file first? Can I also use it with a protected file? Is there another option to make a CD?

    Making CDs has absolutely unequivocably nothing to do with using ExeShield to protect your published executable.
    I have posted on other sites that it's quite possible to use ExeShield to protect your Director executable. It's easy to test with their trial version of ExeShield so I'd suggest doing that first to make sure that's the product you want to use before you purchase it.
    For more info on burning your executable to CD, you can search the forums here....
    ... or try the forums at http://director-online.com/forums/ ...
    ... or check these other links out here:
    http://www.adobe.com/cfusion/search/index.cfm?loc=en_us&term=creating+a+fast+launch+CD&s_p ageName=http%3A%2F%2Fwww.adobe.com%2F&s_channel=Adobe+Homepages&siteSection=home

  • How can I associate 2 appleids with one account or use a different Appleid for imessage as described in another post?

    How can I associate 2 appleids with one account or use a different Appleid for imessage as described in another post?
    I have rejoined the iPhone community, not with one iPhone but with two. My wife agreed to move from the unenlightened!
    I have set up both under my apple account and want to keep it that way. But I do not want iMessages going to both phones. I would like separate message queues but share all apps and other purches from the store.
    I have created a separate AppleID for her but under Settings>Message>Receive At (it currently says 2 addresses) > ... will not allow me to change the current eMail address and when I add hers (her appleid) it errors out. The only thing I can do in the Apple ID field is to manage my account and not change it to hers.
    How can I have 2 iPhones (and my iPad) on the same account but have separate identies?
    Thanks,
    LpGrumpy

    1. Yes. Restart with the Option key held down as needed.
    2. No, it won't be a problem.
    (83373)

  • How can I email a pages 08 document that doesn't have to be opened  as an attachment by the recipient??   PS- I am using at&t mail.

    How can I email a document created on Pages '08 that doesn't have to be opened as an attachment by
    the recipients????
    (I am using AT&T email)

    "when I try save to PDF it just wants to save it to a file?"
    Correct. The difference between "Mail PDF" and "Save PDF" is that the first opens a new Mail message with the file attached. the second saves a file which you may attach to an email message.
    "Terrainathome is a good example of what I am trying to do."
    Not familiar with Terrainathome, but my guess is that the company is sending an email message containing HTML code that downloads what's essentially a web page into the displayed message. To do that, you'll need a website, software that will produce the necessary HTML code, and recipients with email clients capable of interpreting HTML (which is 'most email clients' these days).
    Regards,
    Barry

  • How can I create a video with effects using my ipad?

    How can I create a video with effects (sepia, B&W, Negative, oval or any other shape borders) using my ipad?  I would Like to keep a higher res and also be able to shrink it down to email or send in a MMS. Or should I just upload it to my PC and mess with it there? Some of the apps I have are very easy to use compared to the learning curve needed for video editing software.
    Thanks

    Thats the Problem . . . how many apps do I have to try until I find the one I want? I noticed a few will render the video thus losing its original size. When I went to edit it more in iMovie the video was smaller--not good. And what software do you suggest, Templeton, for the PC? I love the apps because they are easy. I dont have hours to mess around on a software to figure out if its something I want. Im looking for simplicity. Maybe Ill get more into it later. I just want to record simple video of my playing the guitar for self analysis and create a short video for family and friends.
    Apps:
    iMovie
    CinemaFXV
    VideoFix
    Cartoonatic
    Video illusion
    VidEditor
    Software:
    Windows Movie maker (wont accept .mov files)
    After Effects (Too little time, so much to learn)
    Wondershare (Very easy but little choices)
    VideoPad (Again. Few choices)

  • I am using i 4 phone. recently I had a problem with my lap top and had formatted hard disk of it. Now I want to use sync data in my iphone back to itune n my lap top. how can I perform this task with out loosing data in my i phone.

    I am using i 4 phone. recently I had a problem with my lap top and had formatted hard disk of it. Now I want to sync data in my iphone back to itune on my lap top. how can I perform this task with out loosing data in my i phone.

    Hey floridiansue,
    Do you have an installed email program such as Microsoft Outlook?  If your email is through an online login, such as Gmail, etc, then one will have to create an email association with a program such as Microsoft Outlook on the PC for this Scan to Email system to function.
    -------------How do I give Kudos? | How do I mark a post as Solved? --------------------------------------------------------
    I am not an HP employee.

  • How can I email a photo from ipad2 via 3G?  It just shows turning gear and says sending, but doesn't go.  Also, am I not able to use face mail via 3G?

    How can I email a photo from ipad2 via 3G?  When try, only see spinning gear and it says sending, but it never goes.  Also, can facetime be used via 3G?

    Limnos wrote:
    I know somebody with an iPhone and we were told Facetime requires a wi-fi network connection.
    It is on the man. page 45
    Limnos wrote:
    FaceTime works only on WiFi.
    Correct, as I earlier intimated.  It is to stop you from burning through your 3G data limit.
    It won't since it only works on Wifi.

Maybe you are looking for