How to add a hyperlink to javamail attachment?

Hi friends:
I am writing a mail systems.I can receive email attachment using javamail API. But I don't know how to add a hyperlink to the attachment so when user click the hyperlink the file will be download to disc.
I means that I want to add a hyperlink to the attachment,the hyperlink will get the file's path in mail server.Because the mail's attachment are stored in mail server so I don't know how to get it in my servlet.
what I can do is get a inputstream using messagePart.getInputStream();. I only can get a inputstream in servlet.How to change the inputstream to a File when user click it and download it?
Help!
Thks

I am making a same application now...
You have 2 possibilities:
1. Save all the data from the stream to a file That is accessible from the outside through HTTP and then put a link to it
2. Make a link to a seperate JSP page with the following parameters: Folder name (describing where the desired message is), Message id (the number of the message inside the folder) and Part number (you will have to count it yourself). The JSP page then returns all the data.
If you do the second thing, you will have to take care that the first line in the jsp starts with <% because if it does not, the JSP will send an \r\n and that will modify the data.
You will also have to do the following:
response.setHeader("Content-Disposition", "attachment; filename=myfile.txt");
response.setContentType("application/octet-stream; name=myfile.txt");If you know the MIME type, replace application/octet-stream with the MIME type.
Michael

Similar Messages

  • How to add a hyperlink to my Frame?

    Hi everyone:
    I want to add a hyperlink to my swing application .When user click it whick will open a IE and go to mywebsite.But it is so difficult ,my code don't work property.
        je.setPreferredSize(new Dimension(180, 22));
        je.setEditable(false);
        je.setPage("http://localhost:3030/lyomail/html/link.htm");
        final JTextField jf=new JTextField("http://java.sun.com");
        jf.setEditable(false);
        jp.setBackground(Color.orange);
        jp.setDoubleBuffered(false);
        jp.setEditable(false);
        jp.setPage("http://localhost:3030/lyomail/html/mailpic.htm");
        JLabel MyLink = new JLabel("http://www.hotmail.com");
        MyLink.addMouseListener(new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            //Do whatever you want to do here
            URL u = null;
            try {
              u = new URL("http://www.hotmail.com");
            catch (MalformedURLException ex1) {
            try {
              URLConnection ur = (URLConnection) u.openConnection();
            catch (IOException ex) {
        jp.addHyperlinkListener(new HyperlinkListener(){
          public void  hyperlinkUpdate(final HyperlinkEvent ed){
            if (ed.getEventType()==HyperlinkEvent.EventType.ACTIVATED){
              SwingUtilities.invokeLater(new Runnable(){
                public void run(){
                  try{
                    Document doc=je.getDocument();
                    URL u=ed.getURL();
                    je.setPage(u);
                    jf.setText(u.toString());
                  }catch(Exception e){
                    System.out.println(e.toString());
        });The Runtime.getRuntime().exec can do this well.But how to get user's Explore 's path? Where he install IE?
    THks!

    Hi
    I change my code to :
    try{
                        Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler http://localhost:3030/lyomail");
                      }catch(IOException ed){
                         System.out.println("E:"+ed.toString());
                }But it can't work now. It report error when I run it
    java.net.ConnectException: Connection refused: connect

  • How to add a hyperlink in Keynote 6.2 ???

    Hi all,
    I am trying to do something that should be really simple: add a hyperlink to a text object in Keynote. I have not found any way of doing this. In some articles I read something about a hyperlink inspector, but my Keynote doesn't have such an inspector.
    So: how on earth do I accomplish this ???

    my Keynote doesn't have such an inspector.
    All versions of Keynote have an Inspector.
    You have decided not to say what version of Keynote you are using:
    In the latest version 6.5, the Inspector is not used for hyperlinks, instead select the text box, right click and choose add link    

  • How to add a hyperlink in the text caption?

    Hi,
    I am using Captivate 5. Anybody knows how to insert a hyperlink in a text caption? For example, the texts in the text caption are "See Adobe Captivate Forum for details." How to create a hyperlink for "Adobe Captivate Forum" which leads to the forum website?
    Thanks,
    Helen

    There is no tru hyperlink object in Captivate as such.
    You can use a button or a click box to provide users with an interactive object that when clicked will call a URL or document.
    However, this doesn't really give you a mouse rollover effect the way users are accustomed to seeing in normal web hyperlinks.
    If you really want to add a piece of on screen hyperlinked text (with rollover effect) to a Captivate project, the closest you'll come to it is this widget: http://www.infosemantics.com.au/hyperlink

  • How to add a hyperlink to a jpg banner image

    Where the here is i need to add a hyperlink, the image is a jpg.
    Regards Peter

    Here is the HTML simply substitute your web page and image path:
    <a href="http://www.ama-assn.org/"><img border="0" img src="
    http://forums.adobe.com/servlet/JiveServlet/downloadImage/2-5087740-299746/257-106/bannerf an.png
    ">

  • How to add a Hyperlink to open popup in dynamic data grid?

    Hi,
    I am a new bie in FLEX, the question which I am asking might be very easy but i am not able to find solution to it. Please can some one help me.
    I am creating a data grid dynamically using action script code now I want to add a Hyper link to couple of columns in a row. How can I do it in FLex?
    Thanks.

    HI Prashant,
    Thanks for the reply.
    This is what I am currently doing right now:
    for 
    (var i:int=0; i<colNameList.length;i++) { 
    var headerText:String = colNameList[i] + ""; 
    callSellGridCol = cols[i];
    callSellGridCol.headerText = headerText;
    if(headerText != null && headerText == "RIC"){
    var myRenderer : ClassFactory = new ClassFactory(com.db.carving.synthetic.dma.view.UrlLinkRenderer);
    In My Renderer class :
    public 
    class UrlLinkRenderer extends LinkButton{
     public var clickFunction:Function; 
    public function UrlLinkRenderer() { 
    super();}
    // Override the set method for the data property. 
    override public function set data(value:Object):void{
    super.data = value; 
    if (value != null){
    label = value[DataGridListData(listData).dataField];
    else{
    label =
    super.invalidateDisplayList();}
    Now what i want is to add a new Event Listner to this object so that I can click it?
    In your suggestion you said:
                         var classFacory:ClassFactory = new ClassFactory(LinkRenderer); // here LinkRenderer is any mxml/ as file Having Link Button defined.
    Where should be the Link button defined??
    Thanks.

  • How to add several hyperlinks in a graph on different location

    Hi,
    I have been able to create hyperlink using srw.set_hyperlink() for text report.
    I create a bar graph to show data monthly, (Jan, Feb, ..., Dec), thus showing 12 bars in a bar graph.
    I need to make different hyperlink (to drill down) for each month.
    So when user click one of the bar (i.e January bar), then it will drill down to data for January.
    Is there possible to create several hyperlinks in a graph, to link to different location?
    If possible, where should I put the srw.set_hyperlink()?
    How can we handle, the location to be placed with the srw.set_hyperlink()?
    What if it is a pie graph, can we do the same?
    Many thanks,
    Buntoro

    Hi Fazith,
    thanks for your answer.
    I have tried it:
    a=CROSSTAB_1.getSelectedMember("OD_NW_Regio").text;
    APPLICATION.opennewWindow("http://www.wetter.net/47/"+a);
    For testing, I want that the name of the city which is filtered with Dimension OD_NW_REGIO should be added to the url wetter.net (it should show me the weather for the selected city).
    But this script didn't work. I think i have to define "a" or not?
    And according to the onselect function, will the separate report (in this case the weather-side for the selected city) open automatically, or must I click anything?
    Thank you for your help.
    Kind regards,
    Heike

  • Anyone know how to add a hyperlink to the HTML Gallery template?

    In previous versions, I created a modified HTML template which included a link back to a specific page. This placed the link on ALL of the Index pages. Now I must modify HUNDREDS of indices to accomplish the same thing. There has GOT to be a better way!

    With iOS 5 in the Autumn (from http://www.apple.com/ios/ios5/features.html#more) :
    Even add and delete mailbox folders on the fly.

  • How to add a hyperlink to a image button in theme area?

    Hi!
    We need to make an image button (on the theme area) to be
    clickable -- i.e., once you click that image button, it will
    call www.yahoo.com.
    Please advise how to do it.
    Points guaranteed. Thanks!

    Hello,
    Maybe this will help you?
    http://help.sap.com/saphelp_nw70/helpdata/en/9d/52f973810cb448842e35e13ad6c992/frameset.htm
    Gene Madikrama

  • I know how to add a hyperlink to text or image but am stumped with the CSS buttons provided by DW.

    Doing my first web page and was trying out the CSS buttons in the widgets.  Can't see where to set the property for the web link.

    <a href="#" class="classname">my button</a>

  • How do you add a hyperlink on the latest Keynote?

    I want to know how to add a hyperlink in the latest Keynote.  I am running Yosemite.  I have a Macbook Pro 13 inch.  Thank You.

    right click an object on the slide
    choose;   Add Link
    in the Link To, dropdown menu;    select Webpage
    in the Link text, entry box;   type the URL in the form:   www.mypage.com

  • How to add this spectrum bar in labview?

    anyone knows how to add the spectrum bar  ( see attached file, arrow6) in labview and make the plot displays different color when Y value falls to different range?
    many thanks
    Message Edited by lksusier on 11-12-2008 10:12 PM
    Solved!
    Go to Solution.
    Attachments:
    intensitygraphchart.png ‏68 KB

    Try this.
    LabVIEW Champion . Do more with less code and in less time .

  • How do I add a hyperlink to an image in my Mail signature

    In outlook I can simply add a URL to an image in a signature like in the image I've attached. When I try to add a link to an Image in Mail it changes the image to a blue underlined link. How do I add a hyperlink to an image in my Mail signature?

    Hello,
    http://allforces.com/2006/04/14/css-signatures/
    http://timmargh.net/archive/2006/05/custom_css_signatures_in_mailapp.php

  • How to add hyperlinks in Import Manager

    Dear MDM-gurus!
    I really tried hard to find the solution, but couldn't find it here or in OSS.
    We already have a repository with more than 50.000 items.
    What I'd like to do is to add hyperlinks to PDF-files in the internet to each item.
    For this we got an excel-file from the supplier with the supplier part number in one column, the PDF-link in another column and the .
    In Data Manager I was able to add links manually or also with importing entries of the excel-file. Importing from excel takes a LOT of time. I don' t know why:
    -  Fields to import: Hyperlinks
    -  Key fields: Supplier part number.
    --> Action: Update all single matches.
    How can I import hyperlinks in Import Manager, make the mapping and then update the records faster? E.g. I could not find the field "URL <Hyperlink> [Qual]" in Import Manager
    Thanks for your help and best regards,
    Henning

    Resolved!
    I accidently oversaw the URL fields in Import Manager in table catalog items.

  • How do I add a hyperlink in Preview 8.0 (Yosemite)?

    How do I add a hyperlink in Preview 8.0 (Yosemite)?

    Can't I just click on the link and have it go top the site? 
    The presentation must be in play for the link to be active.
    I get the window shown here.
    Your link doesnt work as it is an address for a file on your computer. Use the camera button in the menu bar of a reply to a post to show images.

Maybe you are looking for

  • Please let me know if this is possibe, and how to do it.

    hi, can some one let me know how to achive the o/p mentioned below. with  target as (select 100 profile , 2 key , 'XYZ' value  from dual union all select  100,2,'ABC' from dual union all select  100,2,'CDE' from dual union all select  100,3,'300' fro

  • Why can't I see my installed profile on my Apple TV?

    I created and installed a WiFi profile using Apple Configurator 1.2.1. on my Apple TV 3rd Gen running 5.2.1. I waited until the Green icon with the check displayed showing successful installation of the profile. I then removed the USB cable and press

  • How to add check box to the forms in scripts

    Hello experts,          i got one requirement. to add a check box to the form. how can we add a check box in form. is it possible to adda check box in scripts? thanks in advance.

  • "your request is temporarily unable to be processed" itunes store

    after i have typed all my info and clicked continue , the message always appears "your request is temporarily unable to be processed" have any suggestions on how to fix it ?

  • Service URL not found:session

    Hi, I had written a custom authentication module according to the sample given with SunONE doc. But, when I try to login to the portal server, it is throwing the following exception in /opt/SUNWam/debug/amSSOProvider file. how to solve this issue: I