Search code examples
htmliframepathsrcpageload

Displaying local htm file in iframe?


I am saving some emails on my local machine using MailBee.NET Objects in htm format. A separate folder is created for each email using email messageID on server for example

D:\Emails\GmailId1380ec660e0e656a\doc.htm

is an email downloaded from gmail. I am saving also the above mentioned path in database so I can use it later. Now I am trying to display this htm file in an iframe but it is not working. A user clicks on email which takes him to the read_email page on which I am trying to assign the path mentioned above to an iframe but the iframe remains blank.

emailMessage.Attributes.Add("src",commandReader["email_message_path"].ToString());

emailMessage is the name of iframe and commandReader is normal SqlDataReader which I am using to read the path of the file mentioned above and then assigning that path to src attribute of iframe, I have placed this code in page_load event.

But as I said Iframe remains blank. Please help me out.

Thanks.


Solution

  • Local files are referenced with the file URI scheme. If your email message path is only D:\Emails\... then you'll have to prepend it with file:// :

    file://D:\Emails\...
    

    Note that most browser will prevent you from including a local file from a remote website !.