Send JasperReport to the Email ID which takes values from ResultSet

My objective is to send jasper report to different email ids which takes values from database.
I have wrote the following code. However, it does not throw any error or exception and doesn't meet my objective.
Jdev 11.1.1.5.0 ADF BC.
public void dbConnect() throws Exception{
String dbUrl = "jdbc:oracle:thin:@localhost:1521:testdb";
String dbClass = "oracle.jdbc.driver.OracleDriver";
String query = "Select * FROM testJob";
Class.forName(dbClass);
Connection conn = DriverManager.getConnection(dbUrl,"sahar","sahar");
Statement statement = conn.createStatement();
ResultSet resultSet = statement.executeQuery(query);
String seqNo = null;
Map reportParameters = new HashMap();
Context env = (Context)new InitialContext().lookup("java:comp/env");
String reportPath = (String)env.lookup("reportPath");
String jrxmlFileName = reportPath+"testJob.jrxml";
String jasperFileName = reportPath+"testJob.jasper";
String pdfFileName = reportPath+"testJob.pdf";
while(resultSet.next()){      
String branchId = resultSet.getString(1);
reportParameters.put("branchId", branchId);
JasperReport jasperReport = JasperCompileManager.compileReport(jrxmlFileName);
JasperPrint print = JasperFillManager.fillReport(jasperReport, reportParameters, conn);
JasperExportManager.exportReportToPdfFile(print,pdfFileName);
String subject = "Test with Attachment";
Properties props = new Properties();
props.put("mail.smtp.host", "10.0.0.237");
Session session = Session.getInstance(props, null);
MimeMessage message = new MimeMessage(session);
String toAddresses = resultSet.getString(4);
message.setFrom(new InternetAddress("[email protected]"));
message.addRecipients(Message.RecipientType.TO, toAddresses);
message.setSentDate(new Date());
message.setSubject(subject);
MimeBodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText("Hi");
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(pdfFileName);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(pdfFileName);
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
}

Hi,
refer this threads:
Re: Smartforms to PDF
Re: smartform (otf) as pdf and sending as email-attachment
rgds,
latheesh

Similar Messages

  • Need Text variable for Bex which take values from another variable

    Hello ,
    I have a requirement to show date values in query description.
    User want to run a query which runs for 5 sept till last sunday.
    I have one exit which provides last week date range ( low= last week monday  & high = last week sunday )
    i have acheieved this by restricting 0calday by range = (5 sept 2011 to exit (above metnioned exist's low) + 6 (offset)
    now the problem is user wants to show this date range in query description .
    ie suppose user is runnig this query today so the query description should be  "5 sept  2011 to 2 oct 2011 "
    This could be possible with text variable  by using replacement path , but i am unable to figure ot the logic .
    Kindly advice .
    Regards,
    CR

    Thanks Sushant ,
    In the Tab "Replacement Path " ..there is a drop down -
    "Replace variable with" what should be choose in this ?
    I have used this selections for genearl tab  -
    General Tab -
    Processing By = Replacement Path

  • I receive daily emails from the NY Times, which I read from my Ipad. Some of the emails will show all of the stories available, and some will only show a few lines in the body and the rest of the email is blank. Any ideas of what I need to do to fix this?

    I receive daily emails from the NY Times, which I read from my Ipad. Some of the emails will show all of the stories available, and some will only show a few lines in the body and the rest of the email is blank. Any ideas of what I need to do to fix this?

    Try a reset: Simultaneously hold down the Home and On buttons until the device shuts down. Ignore the off slider if it appears. Once shut down is complete, if it doesn't restart on it own, turn the device back on using the On button. In some cases it also helps to double click the Home button and close all apps from the tray before doing the reset.

  • I can not open email attachment which is sent from a swann dvr using apple mail since i upgraded to Yosemite ,has anyone got a fix ? the file format is _mnt_tmp_

    i can not open email attachment which is sent from a swann dvr using apple mail since i upgraded to Yosemite ,has anyone got a fix ? the file format is _mnt_tmp_

    Oh no... NOT THE 99-PAGER!!! Anything but THAT!!!

  • How I download a MP4 series of videolectures (that the seller has stored in Amazon S3 and has sent to my iPad email address--which is different from the one I use from the MacBookPro) from my iPad to my MacBookPro-.

    How I download a MP4 series of videolectures (that the seller has stored in Amazon S3 and has sent to my iPad email address--which is different from the one I use from the MacBookPro) from my iPad to my MacBookPro (so that I can the save them in iTunes and then synchronize some of the videolectures to the iPad?)

    To set it up as POP you need to delete the account, reboot the phone by holding the HOME and SLEEP buttons at the same time until an Apple logo appears (about 10 seconds), then add it back following these instructions: Forcing creation of a POP or IMAP email account
    I understand that you have used the same account for many years, but the technology is also changing constantly. Years ago the standard was POP (Post Office Protocol), which was designed at a time when it was inconceivable that anyone would access their email from more than one device. When people started using multiple devices, for the most part they wanted to see changes on one device mirrored on another. A new standard, IMAP (Internet Mail Access Protocol) was developed. With iMAP the master copy of all messages resides on a server, and multiple devices are kept in sync with the server. So if you delete a message from one device it is removed from the server, and then removed from all other devices when they next sync. This is the same way Microsoft Exchange works. Other benefits of IMAP include the ability to have multiple mail folders that are kept in sync across devices. In your case you could use this to create a separate folder for each family member, so they could move messages to their own folder and not clutter up the shared Inbox. Most computer mail readers can even automatically sort incoming mail into folders based on the contents of the message.
    IMAP is considered a "higher level" standard than POP. When you create a mail account iOS devices query the server and ask what it supports; if it says it supports IMAP then the account is automatically configured for IMAP. So if you really want POP you must fool it, as described in the link above. In my experience Android devices default to the highest level protocol also, and I suspect newer Blackberries do (although it has been 15 years since I used a BB).

  • Can we change the font in the email that is being sent from SAP ?

    Hi,
    I have a requirement where in we need to change the font for the contents in the mail being generated from SAP.
    I am using the FM SO_DOCUMENT_SEND_API1 to send my mail.And the contents are just appened to an internal table as text elements.
    Can we change the font in the email that is being sent from SAP  to Arial 10points?

    E-mails generated with that function module are created in plain text format.  The font that would appear when reading the e-mail would be dependt on the user's setting for the e-mail application (e.g. Outlook).
    To my knowledge, the font cannot be affected during it's creation.
    Hope this sheds some light on your issue.
    -Mark

  • Why can I not use the channel name, which is obtained from the function of DAQmx Task, as the input of the channel name for the function of Get Channel Information of DAQ?

    Why can I not use the channel name, which is obtained from the function of DAQmx Task, as the input of the channel name for the function of Get Channel Information of DAQ?

    Not a lot of details here, but my guess is this isn't working for you because you are wiring in the task to the Active Channels Property and not the actual Channel Name. I have attatched a screenshot of what I believe you are trying to do. The Task has 2 channels in it, so I need to index off one of the channels and wire it into the active channels input of the Channel Property node. Then I can read information about that channel
    Attachments:
    channel_name.JPG ‏69 KB

  • Hi. the email application has been removed from my ipad. I don't have back up so how can I get it back?

    Hi. the email application has been removed from my ipad. I don't have back up so how can I get it back?

    It is not possible to remove the Mail app (or any other of the bundled apps) from the iPad. It's probably been moved to another Home screen or inadvertently placed in a folder. If you can't find it, you can reset the Home screens in the General -> Reset preferences.
    Regards.

  • Why can't I get my iphone to import all the email address  when it imports from address book?   It syncs all other info. It make we want to go back to my blackberry

    Why can't I get my iphone to import all the email address  when it imports from address book?   It syncs all other info.
    I tried over and over, there must be something I need to change.
    It make we want to go back to my blackberry

    Usually restoring from backup eliminated the corrupted files. However, sometimes restoring to factory settings/new iPod is required.
    To restore from backup see:
    iOS: How to back up
    To restore to factory settings/new iPod see:
    iTunes: Backing up, updating, and restoring iOS software

  • The default value as "None" for the report filter which is Value List type?

    Hello,
    I want to know is it possible to make the default value as "None" for the report filter which is Value List data type?
    For example:The Project Classification Value List value type which have many value like "Supplier Rationalization" "Category Sourcing" "Contract Regegotiation" etc, and the value "Supplier Rationalization" is in the frist positon in the value list. When i use "Project Classification " as a report filter, the value "Supplier Rationalization" displayed as default value. And in the value list box in report filter of Project Classification , there is a value "None" which should be added automatically by system. So i manually filled the default value with "None" in Filter Prompt screen, but it does not work. After i display the report ,the Project Classification filter still use the ""Supplier Rationalization" as the default value.
    My current ESO version is 5.1. I tried other ESO version like 5.15, if i manaully give a default value "None" in Filter Prompt screen for filter Project Classification, then the default value is "None". It works well.
    Does anybody know if it's possible to do the same thing in ESO 5.1?
    Thanks & Regards,
    David
    Edited by: David Gao on Aug 11, 2010 4:06 AM

    Hi David -
    This is possible, but the technique is not too obvious...
    To make "None" be the default choice for a query definition filter parameter of type value list type, you need to set the default value of the filter parameter to the following:
    <internal id of value list type>:616:NULL
    For example, I believe you will see that the internal id of the Project Classification value list type is 51, so the default value of the filter parameter would be:
    51:616:NULL
    I hope this helps.
    Regards,
    Rob

  • After ios 5 update are the email folder empty. an restore from backup won't help.. any ideas?

    after ios 5 update are the email folder empty. an restore from backup won't help.. any ideas?

    I Was wodnering of you ever had ths issue resolved.  My wife's iPad 2 is havieng a similiar issue.  The iPad receives only some emails -- they appear to be from people in her contacts-- but not emials from "strange" soucrces.  No junk mail rules are set.  And oddly enough it is a new iCloud email address.
    What happened to your issue?
    Here is the link to my disucussion:
    https://discussions.apple.com/message/18105173#18105173

  • HT4898 So, the emails I have not deleted from my mac will not be available after I move to iCloud?

    So, the emails I have not deleted from my macbook will not be available after I switch to iCloud?
    Also, I have an iPhone4 and an original iPad.  Will these, along with my macbook, still be compatible?  IE synched?

    Margaret1947 wrote:
    So, the emails I have not deleted from my macbook will not be available after I switch to iCloud?
    That is incorrect, archive them now and restore them later, if they are Mobile Me emails they will move to iCloud without you doing anything, but you should still archive them first.

  • Is the email that appears to be from Adobe and advising of a free upgrade being available a legitimate email from Adobe?

    is the email that appears to be from Adobe and advising of a free upgrade being available a legitimate email from Adobe?

    And what mail? Without seeing a screenshot and other info nobody can say anything.
    Mylenium

  • How can I use iCloud to receive emails from my GMail account and when I reply, the reply email shows the email in which it was sent to, not the @iCloud address?

    I have my GMail account forwarding my emails to my @iCloud.com account which I like, but when I reply, it shows my address as @iCloud.com instead of the email address that was originally addressed to. Anyway to have iCloud reply to emails using the email address in the original email?

    You can't use iCloud's outgoing server to send with anything other than the iCloud address as the 'From' address. On your Mac you can set Mail to use the GMail outgoing server with your iCloud account (but then you can just access your GMail there anyway, so there's little point). On the iCloud website you can't do this; there is no way of using your Gmail address.

  • Need to send attachments in the email

    Hi,
    I'm trying to write lines in a file. Not all of my lines are not written into the file.
    So I'm writing line by line into the file whcih its failed at say 350lines. after that its no more writing the data.
    Please anybody let me know how i can write my data into a file (say 2GB) and send the same as an attachment in the mail.
    Thanks in Advance.
    [email protected]
    Here is the sample code which i'm using
    Declare
    Cursor C1 is
    Select * from my_table;
    line1     Varchar2(32767);
    heading1     Varchar2(32767);
    end_of_line     Varchar2(32767);
    fileHandler     UTL_FILE.FILE_TYPE;
    file_name     VarChar2(100);
    po_err_msg varchar2(1000);
    Begin
    --Open a file in my logical dir 'TEST_UTIL_DIR' for Write
         Select lpad(my_File_Seq.nextval,10,'0')||'.html' into file_name from dual;
         fileHandler     := UTL_FILE.FOPEN('TEST_UTIL_DIR', file_name, 'W');
         line1     := '<table border="1">';
    --Writing first line
         Utl_File.Put_Line(fileHandler,line1,False);
         heading1 := '<tr><td><b>'||'Emp No'||'</b></td><td><b>'||'Employee Name'||'</b></td><td><b>'||'Age'||
    '</b></td><td><b>'||'Gender'||'</b></td><td><b>'||'Relation'||'</b></td></tr>';
    --writing second line
         Utl_File.Put_Line(fileHandler,heading1 ,False);
         For i in C1
         Loop
              Begin
                   heading2      := '<tr><td>'||rpad(i.Emp_no,6,' ')||'</td><td>'||rpad(i.Emp_name,30,' ')||'</td><td>'||
                   rpad(i.Age,5,' ')||'</td><td>'||rpad(i.Gender,3,' ')||'</td><td>'||rpad(i.Relation,8,' ')||'</td></tr>';
    --in the loop
    --for each record
    --writing each record in the file
              Utl_File.Put_Line(fileHandler,heading2,False);
         Exception
              When Others Then
              Print(sqlerrm);
              End;
         End Loop;
         end_of_line     := '</table>';
         Utl_File.Put_Line(fileHandler,end_of_line,False);
         utl_file.fflush(fileHandler);
         UTL_FILE.FCLOSE(fileHandler);
    --sending the file as an attachment.
    demo_mail.send_email(
         P_DIRECTORY     =>'TEST_UTIL_DIR',
         P_SENDER     => 'From_user@my_Company.com',
         P_RECIPIENT     => 'to_user@my_Company.com',
         P_CC          => 'cc_user@my_Company.com',
         P_BCC          => 'bcc_user@my_Company.com',
         P_SUBJECT     => 'Testing in Development',
         P_BODY          => 'Please find the following attachments.',
         P_ATTACHMENT1     => file_name,
         P_ATTACHMENT2     => null,
         P_ATTACHMENT3     => null,
         P_ATTACHMENT4     => null,
         P_ERROR          => po_err_msg);
    Exception
    When others then
    Print(sqlerrm);
    End;
    /

    Numerous threads regarding this issue:
    http://forums.oracle.com/forums/search.jspa?threadID=&q=attachments+in+the+email&objID=f75&dateRange=lastyear&userID=&numResults=15
    Greetings...
    Sim

Maybe you are looking for

  • Using Touch as USB Keyboard

    Hi Does anyone know if there is a way for an ipod touch to emulate a usb keyboard? I am having problems using my wireless keyboard with a new Mac mini. Thanks.

  • Embedded Search delta indexing

    Hello all,    i am trying to create delta indexing for EA-HRXXX component in SAP ECC 6 EH4 on TREX search 7.10 (standalone) but its not taking into account my changes. I created some test data on ECC6 EH4 system related to talent group (new talent gr

  • Frustrated: Novice Illustrator User Needs HELP

    Frustrated: Novice Illustrator User Needs HELP Hello All I am a novice user of Illustrator [after you read my question it will probably be obvious] running Illustrator 14.0.0 (CS4) - on a MAC iMac running 10.4.11.  I am a small business owner and hav

  • Location based query not working Urgent!!!

    Hi I m using orcacle8.1.6 and i m not able to execute the foll query.. select /*+ordered*/ c.customer_id, c.cust_first_name, c.cust_last_name, sdo_nn_distance (1) distance from warehouses w, customers c where w.warehouse_id = 2 and sdo_nn (c.cust_geo

  • Interfacing Zaber Motor through a USB port

    Hey guys!  I'm pretty new to LabVIEW and am trying to control a Zaber T-NM series stepper motor.  However, my computer does not have a free serial port so I'm not sure how to do this through the USB input.  I have a serial-to-USB cable, but I'm lost