After my last episode about adding features to my blog manager program, I've been using it frequently. During this period, the only new feature that I have considered adding is the ability to store the actual blog text and display it within the program. Displaying shouldn't be a problem but I wasn't sure how to save html text (although I have done this in the past, but in those cases, the text was generated within the program and not originally external). I haven't had much time to even think about this, but on Friday afternoon I had the time and space.
I spent a frustrating hour and a half trying to save html text to a new table; my guide was a question on Stack Exchange where someone asked how to save the text displayed within a web browser - not exactly my situation, but close. Big mistake. Eventually I realised that I was knocking my head against a brick wall, so I decided to take the dog for a walk.
As usual, when away from the computer, the beginning of a solution appeared. These blogs are automatically sent to my email account, so I save them in Outlook. I can use the 'save' option to create an html file from each letter. My original intention was to somehow save the text of those files in the blog manager, but when thinking about it, I realised that I was trying to do something completely unnecessary. Save the blogs as files, definitely, but then within the blog manager simply load a given html file into an internal web browser. If the files are named according to their blog entry index number, then no database access is required: if I want to display the text of blog #1617, then all I need do is access the file 1617.html from a predefined directory. Display it if it exists otherwise do nothing. Very simple.
The only problem left is that I run Outlook on a different computer, and anyway there's no automatic way (that I know, apart from automating Outlook - there's an idea for a rainy day) of creating those html files; they also have the wrong name when created and they're on the wrong computer. Trivial problems. Yesterday I created files from all the blog entries from the beginning of May, transferred them then renamed them. The blog manager displays them without breaking a sweat.
To my surprise, pictures included in the blog entry get displayed. I have just had a quick look at the source html code in order to see how this trick is managed: the internal web browser is accessing the picture as it is stored in Blogger! That explains why blogs with pictures load slowly.
const olHTML = 5; procedure TForm1.FormActivate(Sender: TObject); var i: integer; s: string; begin CoInitialize (nil); outlook:= createoleobject ('Outlook.Application'); namespace:= outlook.getnamespace ('MAPI'); found:= false; GetFolder (namespace.folders); myfolder:= myfolder.item[foldernum]; for i:= myfolder.items.count downto 1 do begin s:= myfolder.items[i].subject; if pos ('[Perceptions]', s) = 1 then myfolder.items[i].saveas ('c:\tmp\' + inttostr (i) + '.htm', olHTML); end; myfolder:= unassigned; outlook:= unassigned; namespace:= unassigned; CoUnInitialize; end; procedure TForm1.GetFolder(folder: variant); var i: integer; begin i:= 0; while (i < folder.count) and not found do begin inc (i); if folder.item[i].name = 'Blog' then begin found:= true; myfolder:= folder; foldernum:= i; end else getfolder (folder.item[i].folders); end; end; end.
|
|
Title | Tags |
---|---|---|---|
486 |
|
Dubrovnik log 3 | Kindle, Peter Robinson, Holiday, Dan Ariely, Dubrovnik |
601 |
|
Edinburgh log (5): Around and about | Holiday, Edinburgh, Bagpipes |
722 |
|
Intermission: the tale of the linen jacket (Sorrento log 7A) | Holiday, Sorrento, Italy |
723 |
|
The isle of Capri (Sorrento log 7B) | Holiday, Sorrento, Italy |
1149 |
|
This must be the place | Personal |
1517 |
|
Aches and pains: my first swim of the year | Health, Swimming |
No comments:
Post a Comment