none
outlook - click hyperlink to open savefiledialog RRS feed

  • Question

  • Hi everyone, i have a question to ask.

    from the html codes

    "<a href=""" & ip & """>" & dra.ToString & "</a><br>"

    is it possible to set it so that the a href will open the savefiledialog?

    as in, when i click the hyperlink, it will open a savefiledialog so i can save the file?

     

    please help. thanks

    Monday, January 30, 2012 8:07 AM

Answers

  • I have solved the problem already. Thanks a lot for the help.

    I have used a file portal and used the generic handler to save the file.

    Thanks for all the help!

    Friday, February 3, 2012 10:12 AM

All replies

  • By savefiledialog you mean Open File dialog in office?
    Monday, January 30, 2012 1:06 PM
  • i have this codes that can help me download files from my database

    saveFileDialog1.InitialDirectory = "desktop"

            saveFileDialog1.FileName = getName()

            saveFileDialog1.Filter = getTypes().Substring(1) & " files (*" & getTypes() & ")|*" & getTypes() & "|All files (*.*)|*.*"

            Dim myStream As Stream = Nothing

     

            If saveFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then

                Dim connection As SqlConnection = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\L31303\Desktop\CloudPortal\CloudPortal\PORTALDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")

                connection.Open()

                Dim command As SqlCommand = New SqlCommand("select FilePath from Attachment where AttachmentID = 17", connection)

                Dim buffer() As Byte = CType(command.ExecuteScalar, Byte())

                connection.Close()

                Dim fs As FileStream = New FileStream(saveFileDialog1.FileName, FileMode.Create)

                fs.Write(buffer, 0, buffer.Length)

                fs.Close()

            End If

     

    so i wanted the a href to link to the savefiledialog so i can download the files

    Tuesday, January 31, 2012 2:27 AM
  • It depends - do you have server side code? what is serving html where you want to put links in? Web server? or are you creating it locally and displaying it in embedded web browser control?

    Tuesday, January 31, 2012 8:53 AM
  • im sorry but i do not understand what you mean because i am new to this. 

     

    i do not have any webserver or anything. 

    i have an outlook add-in that allows user to attach files using my button. the attachment name will be placed into the message body as a hyperlink.

    When the user sends the email, the attachments will be stored into my database as a blob file. 

    now i need to change the hyperlink so that when i click on the hyperlink in the message body, it will download from the database by using the savefiledialog

    Tuesday, January 31, 2012 9:31 AM
  • hmm, i;m afraid that only usable events that Word content editor rises for you are BeforeDoubleClick and BeforeRightClick, so not really an option in your current design.

     

    Considering this shortcoming i would rather not insert hyperlink but a special text/field/shape inside word contents and instruct user to double click it to grab attachment. Or i would insert attachment 'stubs' (for example simple txt files) inside mail and handle in my add-in any user interaction with those stubs (right click, attachment opening, etc.) to fetch real attachments. Outlook events in this scope are way more fitted for your needs.

    Tuesday, January 31, 2012 11:02 AM
  •  i would rather not insert hyperlink but a special text/field/shape inside word contents and instruct user to double click it to grab attachment.


    Or i would insert attachment 'stubs' (for example simple txt files) inside mail and handle in my add-in any user interaction with those stubs (right click, attachment opening, etc.) to fetch real attachments. 

    Thanks for the suggestions. But how do i do the above two ways? Can you teach me how? Thanks

    Tuesday, January 31, 2012 11:26 AM
  • How you will implement this is really up to you. Decide what is easier for you and what suits your client. There are appropriate events on Item in outlook, for example BeforeAttachmentRead, BeforeAttachmentPreview. It is up to you to decide if you want to replace attachment on special user action or just display it on demand when user double clicks 'stub' . Or if you/client want to have something clickable inside body's contents, then go with word example. Full sample solution is way outside of scope for this forum, imho.

    Tuesday, January 31, 2012 11:49 AM
  • i tried doing this into the message body. 

    <pre>

    <html>

    <head>

    <script type="text/javascript">

    function savefile() 

    {alert('Hello World - this is an alert message! HI');}

    </script>

    </head>

    <body>

    <a onclick="savefile()"><font color="#0000ff"><u>test</u></a><br>

    </body>

    </pre>

     

    when i send the email, it display out the word 'test' successfully. but i am unable to click on the word to use the function. when i try it out on webpage like w3school, it is working. Is there something wrong with my codes? i am using the language VB.net by the way.

    Wednesday, February 1, 2012 7:00 AM
  • no, drop your approach with html, js will not be executed, so this is dead end. If you want to go with 'body' modification (and i assume we are talking about office 2010 since you did not mention otherwise) use Word API to modify content and capture double or right clicks as i explained above. You get access to Word's Document object by 'Inspector.WordEditor'.
    Wednesday, February 1, 2012 8:43 AM
  • i am sorry but i don't understand how to use Word API to modify content and capture double or right clicks. do you have an example or sample? Please help. Thanks
    • Edited by noobie1 Thursday, February 2, 2012 2:54 AM
    Thursday, February 2, 2012 2:08 AM
  • i'm sorry, but i do not have sample ready. There is plentiful samples on internet to achieve this (for example http://msdn.microsoft.com/en-us/library/aa537149(v=office.11).aspx), search for something that will suit your needs (maybe you want to create small table inside mail body with one column being the name of attachment and second contain text 'Double click here to get attachment'). Search for samples in context of how you want to achieve your goal.
    Thursday, February 2, 2012 11:21 AM
  • Hi noobie1,

    Thanks for posting in the MSDN Forum.

    Would you please tell me whether you use this html code in a Outlook mailitem's Htmlbody?

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Friday, February 3, 2012 7:44 AM
    Moderator
  • I have solved the problem already. Thanks a lot for the help.

    I have used a file portal and used the generic handler to save the file.

    Thanks for all the help!

    Friday, February 3, 2012 10:12 AM