How can I get path from af: inputFile or a uploadedFile

Hi, there,
I am getting error messages while sending attachment.
I firstly tired getting the attachment from <af:inputFile> and attach it to the email. It failed. Then I put the file name directly into my code, still choose the same file from the <af:inputFile>, it failed again. However, from the code you can see, I can get system out println to print the file name, even the file content.
I realized that I might need the file path, but I don't konw how I do get the path, should I write code in the backing bean of uploadedFile or in the send() in the Application Module ? How can I get the path?
any advice is welcome and thank you very much!
The system.out.println result is
08/05/09 11:56:38 2javax.activation.FileDataSource@1674b36
08/05/09 11:56:38 2.1 jkljlj
08/05/09 11:56:38 2.2New Text Document.txt
But the error message still says :
nested exception is:
class javax.mail.MessagingException: IOException while sending message;
nested exception is:
java.io.FileNotFoundException: New Text Document.txt (The system cannot find the file specified)
Here is my code:
ViewObject issueView = getIssueView1();
Row x = issueView.getCurrentRow();
String fileName = "New Text Document.txt";
System.out.println("1 " + fileName);
System.out.println("1.5 " + x.getAttribute("attachmentName"));
// msg.setText(body);
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(body);
Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
// String attachmentName = (String)x.getAttribute("attachmentName");
//if (attachmentName != null) {
MimeBodyPart mbp2 = new MimeBodyPart();
DataSource source = new FileDataSource(fileName);
System.out.println("2" + source);
System.out.println("2.1 " + x.getAttribute("attachment"));
mbp2.setDataHandler(new DataHandler(source));
//mbp2.setFileName(source.getName());
mbp2.setFileName(fileName);
System.out.println("2.2" + fileName);
mp.addBodyPart(mbp2);
msg.setContent(mp);
// send the message!
getDBTransaction().commit();
Transport.send(msg);
System.out.println("\nMail was sent successfully.");
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
}

I wish you and others like you would say what you are trying to do, not how you are trying to do it. That would save those who would like to help the trouble of figuring it out. However, I'm going to make a guess at what you are doing. Tell me if I'm right.
You are writing a page that lets a user construct an e-mail message. I assume that the page has fields like: addressee, subject, and message. It also has a field, defined as an <af:inputFile> component for getting a file to be added as an attachment to the e-mail.
You will want to look at forum posts and tutorials about how to upload a file. You will see that the "value" attribute of an <af:inputFile> will normally contain EL referencing a property of a backing bean which has the UploadedFile class. This class has methods for getting the filename, MIME content type, and an InputStream containing the data in the uploaded file. These pieces of information are all you need to add an attachment to an e-mail. You don't need the file's path, which is a good thing, since that information is not available to you.
I've never used Javamail, so I can't tell you exactly how to use it, but I do understand the basics of sending e-mail. What you are going to do is create a multi-part message. The first part will be the message itself. Subsequent parts are the attachments. Each attachment can have it's filename and MIME content type set. Then you read the file through it's InputStream and write it to the message content. If the file contains binary data, you will need to pass it through a filter that will encode it to the Base64 format - which represents your data as 7 bit bytes.
You will NOT be using the database connection or anything from the data controls to send an e-mail, unless you also need to save a copy to the database. The connection that is needed for e-mail is a connection to an SMTP service. Ask your e-mail administrator for some help with this.
You MIGHT want to write most of this code in your Model project as a business component. Then your backing bean would probably just pass the fields as parameters.

Similar Messages

  • How can I get values from listbox?

    Hi all,
    I need to get price values from Price List (Inventory -> Item Master Data screen). It's important to get values from field 'Price' BEFORE item will be added/updated.
    How can I get values from Pricelist listbox?
    Thanks for any suggestions or short sample code.
    Best regards,
    Andy

    Hi Andy
    Here is som sample code that will get the description of the price list and also the price that is displaying at the time. The item master must be open for this snippet of code
      Public Sub GetItemPriceFromOpenWindow()
            'this is assuming item master is open
            Dim oEdit As SAPbouiCOM.EditText
            oEdit = SBO_Application.Forms.GetForm("150", 1).Items.Item("34").Specific
            SBO_Application.MessageBox(oEdit.Value)
            Dim oCmb As SAPbouiCOM.ComboBox
            oCmb = SBO_Application.Forms.GetForm("150", 1).Items.Item("24").Specific
            SBO_Application.MessageBox(oCmb.Selected.Description)
        End Sub
    Hope it helps

  • HT203167 lost my hard drive how can i get songs from ipod back to new computer

    I lost my hard drive and want to get my music back on my new computer. How can I get songs from my ipod to my computer? I am afraid to sync it and losing what is on my ipod. Any help would be appreciated.

    It has always been very basic to always maintain a backup copy of your computer for this very occasion.
    Use your backup copy to put everything back.
    If for some reason you have failed to maintain a backup, not good, then you can transfer itunes purchases from your ipod:  File>Transfer Purchases

  • How can I get Data from the Sound cart in Labview? Does a VI exist?

    How can I get Data from the Sound cart in Labview? Does a VI exist?

    Yes, there are VIs for acquiring data from Sound cards. And examples too. If you don't have LabVIEW yet, do a search on NI's site for example VIs.
    Khalid

  • How can i get contacts from my old Nokia phone to iphone 4S

    how can i get contacts from my old Nokia phone to iphone 4S?

    Appreciate the reply thank you
    Issue being is I don't have the lead for the samsung any longer but have the memory card?
    An yes I know I need to get them onto my MAC but how is what i'm struggling with?
    Any help would be appreciated.
    Many thanks

  • How can i get data from another database SQL Server use database link from

    I have a database link from Oracle connect to SQL Server database with user cdit connect default database NorthWind.How can I get data from another database(this database in this SQL Server use this database link)?

    hi,
    u should see following documentation:
    Oracle9i Heterogeneous Connectivity Administrator's Guide
    Release 1 (9.0.1)
    Part Number A88789_01
    in it u just go to chapter no. 4 (using the gateway),,u'll find ur answer there.
    regards
    umar

  • How can I get music from old mac to new mac?

    How can I get music from old mac to new mac please?
    Can't seem to make Migration Assistant work. Doesn't ask about or transfer files.

    I just migrated into a new MBP from an old one.
    It did not bring the music over.  Apple's instructions are to use the Home Sharing feature of iTunes.
    Open iTunes on your old Mac.  Select Home Sharing under the Advanced menu.  Sign in.  Do the same on your new computer.  Then when the library appears under Home Sharing on the left-hand panel on your new computer's iTunes, you can select all and Add To Library.
    That's what Apple says, anyway.

  • How can I get sound from tv or stereo when watching netflix on MacBook Air?

    I have my macbook air hooked up to my tv and want to watch netflix but the only sound is from my macbook.  How can I get sound from other sources ie tv or stereo?

    Check with Netflix for their system requirements.

  • How can i get data from a maintance view?

    Hi all.
        Can you give me some suggestion about 'How can i get data from a maintance view?'?
         Thanks
         Best regard

    hi
    good
    go through this link
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ecdf446011d189700000e8322d00/content.htm
    thanks
    mrutyun^

  • How can you get pics from your Camera roll to you photo stream

    How can you get pics from your Camera roll to you photo stream

    iCloud: Photo Stream FAQ
    iCloud: Photo Stream
    iCloud: Set up Photo Stream

  • How can i get input from user in Workflows

    Hello professionals,
    I'm new to SAP B1 Workflow, i have created some workflows and they all worked fine.
    But, I am wondering, How can i get input from user?. For example, i want to display list of options to choose between them and route the workflow based on the selected option. I don't want to use the exclusive gateway and check for some conditions, i want to get input from user.
    How can i do that?
    Thanks in advance,
    Kareem Naguib

    Hi,
    Please refer SAP help file:
    http://help.sap.com/saphelp_sbo900/helpdata/en/b8/1f9a1197214254b79bcf8f93f9fff9/content.htm?frameset=/en/44/c4c1cd7ca22…
    Thanks & Regards,
    Nagarajan

  • I purchased a song (Awaara Hoon (instrumental)) from itune store but it gives me a non-protected m4a file. I need a protected m4p file. How can i get it from itune store??? thanks in advance

    I purchased a song (Awaara Hoon (instrumental)) from itune store but it gives me a non-protected m4a file 
    I need a protected m4p file.
    How can i get it from itune store???
    thanks in advance

    All the music from iTunes Store aren't protected. You can search the web for a site that sells protected music.

  • HT201302 Hi People! please help...I want to know how can i get photos from ipad to the computer, that were synchronized previously to ipad but from another pc that i dont have access anymore and these pics are now only found in this ipad and no other plac

    Hi People!
    Please help...I want to know how can i get photos from ipad to the computer, that were synchronized previously to ipad but from another pc that i dont have access anymore and these pics are now only found in this ipad and no other place.

    Hi Alan,
    Thanks for the help, but i've actually done that before.
    It does not help, because it only shows the photos on the camera roll and do not show the photos synchronized with that pc that i dont have access anymore.
    The photos/albums all appear on the ipad, i can see it without problems but i cant get them out of the ipad to save onto pc for backup.
    And i reaaly need it, as it is the only place that i actually have these photos now...

  • How can I get songs (from CDs) on my Nano onto my laptop?  Do I have to rip all the CD's again just becasue I'm using a different computer?

    How can I get all my songs (from CDs) onto my laptop from my Nano?
    Do I have to rip all those CDs again even though they are on the Nano?
    I thought I was allowed to have multiple PCs and use the sync feature.  Yet when I plug in the Nano the message says it will sync to what's on my laptop which are only a few songs I've purchased!!
    I thought Apple was better than that?!  And to think I was going to purchase an iPad!  But if I can't synch my music to other devices, why bother.
    In order to get my music to iCloud via iMatch, I guess I have to rip them all again!  What a pain in the butt...:(

    See Recover your iTunes library from your iPod or iOS device.
    tt2

  • How can i get apps from my itunes to my iphone?

    okayy so i want to get the facebook application on my iphone and i dont have the app store on my ipone.. soo how can i get the app from itunes to my phone for ffree?
    i have a windows computer
    and i have restrictions on my phone because i use it too much..

    You can turn off restrictions then go to the app store and download it.
    or you can donwoad from the app store on  your computer and sync it to your iphone.
    You should really read the manual.

Maybe you are looking for

  • How to create delivery with lesser quantity than Scheduling agreement

    HI all, I have one Scheduling Agreement SCHDMNT1 with ITEM A and Qty 100. Now i want to create 2 deliveries against this Agreement i.e DEL1 - ITEM A QTY 40 and DEL2 - ITEM A QTY 60. How to achieve this while manually entering the deliveries. What are

  • Oracle 9.0.1 Linux Intel Enterprise version images corrupt  on Downloads

    The Oracle 9.0.1 Enterprise DataBase software for Linux Intel downloadable version on the Oracle Technology Network has 2 of the Disk images currently corrupt. After downloading all the 3 Oracle 9.0.1 Database CD images for Linux Intel from the Oracl

  • PO approval notification email issue

    Hi, When user try to approve PO, it sends email notification to manager who has correct approval athority. Manager can see the approval notification email but notification doesn't have PO Line details section (section which has PO Line information).

  • Workaround: Oracle Networking - LDAP export to TNSNAMES

    Just posting a workaround to another silly problem: With Oracle10g, ONames is no longer supported. A reasonable alternative is to LDAP using OiD. In the docco, Oracle describes a method to export and import between OID and TNSNAMES.ORA. Specifically

  • I will pay for help, Media Encoder and Premiere Pro C4 won't work together

    I know someone has two easy answers...help, help. Big Problem one, exporting from Premiere C4, forced into using Media Encoder, which sit there and won't encode from the project/timeline. The project is even small, 7 minutes, and I just want to me a