Question

Render HTML page and send as e-mail

Asked by: fulscher

Hello experts,

From within an agent, I'd like to read a web page containing pictures and Java Script and send it as E-Mail.

"GetDocumentByURL" fails (don't know why - wrong client type?).

Any idea how to do this?

The URL in question is
http://theyr.net/cg/cny/I1be177/F=js*L=en*u*041010*24*uIL*usia_DesMoines

In addition, I'd like to process a number of pages from different sites and append them to the same document. Ideas?

Additional points will be granted, if required.

Thanks
J

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2004-10-08 at 12:20:22ID21161509
Tags

html

,

send

,

page

Topic

Lotus Notes

Participating Experts
3
Points
500
Comments
31

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Agent behaving Strange !
    Hi guys I have two databases, one copy of the other in two servers (say A and B). IN the database i have a form and a webquerysave agent for that form . The webquerysave agent is able to get all the values in documentcontext in server A. but the same agent is not get...
  2. Web Agents
    I have a web application in R5. One the mail form there is a buttonb which when clicked calls an agent. The problem I have is that some users are clicking this button twice. This is causing errors as the agent is running twice in a row!!! Is there anyway to prevent...
  3. HTML page rendering performance
    I have an HTML page which contains tables, tables within tables, stylesheets, javascripts, some small images, etc. This HTML page is rendered from a JSP. I would like to see if I can speed up the transfer of the page from the server to the browser (Internet Explorer), and als...
  4. OpenGL stops rendering when I start cg
    Hi guys, I’m programming a 3d application with MFC and OpenGL. And ever since I added "cg" I get a small black square at the upper left corner of the screen. And besides the small black square, I see nothing anymore, no wireframe, no polygons... nothing at all! It a...
  5. Encrypting HTML/JS code with JS
    Hello, I would like to protect some HTML/JS code. All words and links should be unrecognizable to the human eye. This tool is almost what I want, but it leave words and links in tact so they can be read. http://www.dynamicdrive.com/dynamicindex9/encrypter.htm I thi...
  6. Rendering XML in HTML
    OK...So I have an XML document that I would like to parse and represent in simple HTML format via AJAX. I have the structure already in place however I am having difficulty showing all sub-elements. Basically, I have a Vulnerability scan output generated in XML from a V...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: p_parthaPosted on 2004-10-08 at 14:02:54ID: 12263092

Is the webretriever running, also i wsa not able to check the URL ,as that site was blocked in our environment,

TO send multiple pages, you can use Notesnewletter class


partha

 

by: fulscherPosted on 2004-10-08 at 14:23:57ID: 12263279

It appears to be ok:

If I set the browser in the location document to be "Notes with IE", the page opens in Notes correctly if opened manually. If I set the browser to "Notes", the page returned is blank. However, GetDocumentByURL fails in both cases.

J

 

by: p_parthaPosted on 2004-10-08 at 17:29:07ID: 12264486

Just to verify , can u give some other URL, and check whether you are getting the value returned

partha

 

by: fulscherPosted on 2004-10-09 at 00:44:00ID: 12265395

You can download a test database from this link:

http://www.fuelscher.ch/files/MetRet.zip

To try, go to view "URLs to load", select one document, run the agent Actions/Get Meteo TEST. A new document opens which is the document just retrieved. Note that HTTPStatus returned is 200 (ok), however, the Body field is empty. This is true for all three URLs in the DB.

partha - the URLs shouldn't be blocked; this is just weather information. Anyway, it won't even work if you try http://www.google.com...

Jan

 

by: RAPUTAPosted on 2004-10-09 at 04:44:17ID: 12265799

The "web" task must be loaded on the server AND the agent must run on the server (client settings are not relevant)

Create an agent "(Test)" with the following code inside the Initialize event. Make sure your test agent has properties "Agent list selection" and "Target: None".

      Dim s As New NotesSession
      Dim c As NotesDocument
      Set c = s.DocumentContext
      Dim d As NotesDocument
      Set d = s.CurrentDatabase.GetDocumentByURL( c.Test( 0 ) )
      If Not( d Is Nothing ) Then
            Print {<div style="font-size: 10pt">}
            Print "<h3>TEST de " & c.GetItemValue( "Test" )( 0 ) & "</h3>"
            Print "<b>Page title</b> = " & d.GetItemValue( "Title" )( 0 ) & "<br>"
            Print "<b>Doc size</b> = " & d.Size & " bytes" & "<br>"
            Print "<b>Status</b> = " & d.GetItemValue( "HTTPStatus" )( 0 ) & "<br>"
            Print "<h4>Headers</h4>"
            Dim headers As Variant
            headers = d.HTTPHeaders
            Forall h In headers
                  Print "<b>" & h & "</b> = " & d.GetItemValue( h )( 0 ) & "<br>"
            End Forall
            Print "</div>"
      Else
            Print "error accessing remote URL " & c.GetItemValue( "Test" )( 0 )
      End If

Then create a new "Test" form with a "Test" text field and a "Test" action button (formula), with code "@Command( [ToolsRunMacro]; "(Test)" )".

Then open this form from the browser in your client through an URL like the following:
  http://www.example.com/path/to/notes/database.nsf/Test?OpenForm
Finally write some URL in the Test field and then click on the Test action

 

by: RAPUTAPosted on 2004-10-09 at 04:50:51ID: 12265807

Previous sample code gave me this output for your URL

TEST de http://theyr.net/cg/cny/I1be177/F=js*L=en*u*041010*24*uIL*usia_DesMoines
Page title = Weather forecast Sun Oct. 10 2004 24:00 UTC
Doc size = 26054 bytes
Status = 200

Headers
HTTPDate = 09/10/2004 13:49:59
HTTPServer = Apache/2.0.40 (Red Hat Linux)
HTTPContent_Language = en
HTTPContent_Length = 24118
HTTPContent_Type = text/html
HTTPAge = 3
HTTPContent_Script_Type = text/javascript
HTTPExpires = 09/10/2004 14:04:59

 

by: RAPUTAPosted on 2004-10-09 at 05:02:51ID: 12265834

Also note that the notesDatabase.GetDocumentByURL method automatically adds a document to your database with an "HTMLForm" value in the form field.

If you want to send that page by email you can simply make a call like the following
  Call notesDatabase.GetDocumentByUrl( anURL ).Send( False, toSomeone )
because Notes put the Title of the page also in a Subject field and page itself is in the Body field

 

by: fulscherPosted on 2004-10-09 at 05:33:09ID: 12265903

RAPUTA,

your code basically does the same as mine. So, I tried to run my agent on the server and the results are better - some URLs are retrieved more or less successfully. And, of course, Notes renders the documents just awfully but that probably was to be expected.

Please try the following URLs:

http://www.wunderground.com/US/NY/Kennedy_International.html
http://www.wetter.com/v2/

In both cases, the document is only loaded partially, the BODY field contains only part of the document.

Any idea how to resolve this?

Or even better - any idea how to get a better rendering of the result?

J

 

by: p_parthaPosted on 2004-10-09 at 07:01:51ID: 12266140

if you say doc.body(0), u will get only partially ... you have to use something like this


forall x in body
msgbox  x
end forall

 

by: fulscherPosted on 2004-10-09 at 07:52:57ID: 12266282

partha,

right. The partial documents have only one Body item and the item is only 1177 bytes long for one of the damaged documents (1127 for the other). I rather think there's a problem with creation of the document...

Jan

 

by: RAPUTAPosted on 2004-10-09 at 08:18:58ID: 12266393

Your suggested URLs work for me (only 1 Body field, BTW):

http://www.wunderground.com/US/NY/Kennedy_International.html --> body.length = 2563 bytes
http://www.wetter.com/v2/ --> body.length = 4087 bytes

So my suggestion is: first try my solution exactly as described. In this way you can discriminate between something wrong with your script (if my solution works also for you) or something wrong with your server (if my solution doesn't work for you).

 

by: RAPUTAPosted on 2004-10-09 at 08:38:02ID: 12266447

no, i was wrong, sorry

The first page is much greater than what Notes receives...

 

by: RAPUTAPosted on 2004-10-09 at 10:01:48ID: 12266937

I don't know for sure what causes the truncated body, but I think it's not a problem with my code, neither with the notes server. In fact, I created a page in my notes database with the html from the "wunderground" url and then I tried to access it trough my agent, and it works !!

 

by: HemanthaKumarPosted on 2004-10-09 at 10:02:21ID: 12266940

Other solution is not to use web task on server.. this will kill the server in production environment where there are lots of other tasks are involved. Better approach would be to use local web navigator...and set the location to Notes with IE.. This will render your html page far more better !

Although I would suggest java solution for this...

It is easy to write one and format email in mime format and send it...

~Hemanth

 

by: fulscherPosted on 2004-10-09 at 15:09:18ID: 12268281

Hemanth - do you happen to have some sample code?

Raputa - if the problem is not with the code and neither with the server - where is it then?

J

 

by: p_parthaPosted on 2004-10-09 at 16:42:48ID: 12268526

when there are changes in the page through DOM or javascript, it will not be reflected in the source.... So u will get only partial output..

Also as Hemanth suggested, the best thing would be to use Java agent. It;s very easy as there are lot of methods in URL class

see this and then build upon this:

http://www-10.lotus.com/ldd/46dom.nsf/55c38d716d632d9b8525689b005ba1c0/c329f4fabec2612185256a6a000632b8?OpenDocument

 

by: fulscherPosted on 2004-10-10 at 01:27:09ID: 12269514

all - I really appreciate your help.

It appears that Domino isn't very well suited to this task. For example, I still don't understand why Raputa got more bytes from the sources than I got; looks like Domino doesn't handle HTML very well after all.

To get back to the requirements: I need a function / program which reads one or more HTML pages and renders it/them to an E-Mail. Background: I'd like to have weather forecasts from different sources every day. The thing may be an agent, a server task or an independent program on the server; doesn't really matter.

The thing should run on the server (after all, if it runs on the client, I could as well look up the HTML pages directly). Rendering should be more or less accurate, i.e., the e-mail should be interpretable.

p_partha: The code sample you linked to tests whether an URL is valid. The part I need (reading the web page and inserting it into an e-Mail) is not there.

Btw: I'm running Domino 6.5 on the server.

Any ideas?

 

by: HemanthaKumarPosted on 2004-10-10 at 07:41:17ID: 12271214

fulscher,

I don't have the code ready made.. but you can check the help documentation (java section) on how to handle mime !

The link partha proposed is one way to read html page and store it in a buffer. use that buffer to parse in the body content to the mail. You can also use sockets.. but httpurlconnection would be ideal..

 

by: RAPUTAPosted on 2004-10-10 at 08:29:53ID: 12271511

I thought the same as p_partha about the javascript modifying the document and tried a simple page but it worked properly, so maybe my javascript was too simple or the problem is not there or not all there...

If your server is Win32, you could use the following function to put a page in a string. It's based upon a service of the MSXML library, which is installation is easy (and maybe it's already running)

Function GetPage( url As String ) As String
      Dim objHttp As Variant
      Set objHttp = CreateObject( "Msxml2.ServerXMLHTTP" )
      Call objHttp.Open( "GET", url, False )
      Call objHttp.Send()
      If objHttp.status <> 200 Then
            GetPage = "FAILED (status: " & objHttp.status & ")"
      Else
            Dim contentType As String
            contentType = objHttp.getResponseHeader( "Content-Type" )
            If contentType = "text/html" Then
                  GetPage = objHttp.responseText
            Else
                  GetPage = "Not HTML (type: " & contentType & ")"
            End If
      End If
      Set objHttp = Nothing
End Function

 

by: fulscherPosted on 2004-10-10 at 08:42:46ID: 12271554

RAPUTA - thanks - I like this. However, I need the images and layout of the page...

Hemanth - I've been trying HTML-to-MIME earlier and somehow did not find it to be very easy to create a MIME mail from a HTML page. I'll check again.

Any other options / ideas? Somebody with some functioning sample code? (well, just asking...)

J

 

by: RAPUTAPosted on 2004-10-10 at 09:05:03ID: 12271626

 

by: RAPUTAPosted on 2004-10-10 at 09:36:25ID: 12271715

 

by: fulscherPosted on 2004-10-10 at 09:59:26ID: 12271779

Raputa - sorry, this is over my head. Can you give me a hint on how to continue from these pages?

 

by: RAPUTAPosted on 2004-10-10 at 10:02:32ID: 12271790

well, the images can stay where they are I think... if you let them load from their domain, ins't it ok? and the layout should be the html itself

 

by: RAPUTAPosted on 2004-10-10 at 10:39:04ID: 12271914

It's very easy, just download the first file and run it on the server to install.
Then start testing the function

 

by: fulscherPosted on 2004-10-10 at 11:43:08ID: 12272155

Actually, I'd like to have a complete rendering of the page without external links.

Reason: I want to keep the forecasts in my mail DB for comparison and later analysis. So, if the images are linked to, they might not be available any more (actually, many of them will change at least one a day).

Sorry for the complications, but keeping the images was the reason I asked for rendering them to a Notes document...

J

 

by: RAPUTAPosted on 2004-10-10 at 13:57:05ID: 12272667

It seems now much more difficult... you want to create a browser in Notes !!!

 

by: fulscherPosted on 2004-10-10 at 14:49:23ID: 12272809

Raputa - I don't want to create a browser in Notes. The question remains still the same.

Quote from the original question:
"From within an agent, I'd like to read a web page containing pictures and Java Script and send it as E-Mail."

So, I want either "GetDocumentByURL" to function correctly (it would do what I need) or find replacement code to "GetDocumentByURL".

I've not yet been looking at the Java samples (my Java is quite rusty and I would need a day or to just to get up and running again), but I'm certainly willing to do so IF it solves the problem. However, I'm not sure about this - reading a HTML string from a web site does NOT solve the problem. if I could read an image and insert it into a Notes document, the problem would be party solved.

Ideas? Suggestions?

J

 

by: RAPUTAPosted on 2004-10-11 at 04:46:23ID: 12275359

fulscher,

GetDocumentByURL really does not integrates the images in the rich text field like you can do with a paste from the clipboard, but it puts the html in the Body field as it is.

So if you want to get to the images, you could iterate through the IMG tags (or the values in the field $ImageList) and try to get the filed from the internet cache directory, along with all the others needed files, such as stylesheets and javascripts

 

by: fulscherPosted on 2004-10-11 at 06:48:01ID: 12276264

all - thank you for your input and comments so far.

I've been playing some more with various methods and I've come up so far with something that appears to work. I restrict myself to images for the time being, since the images are the most important bit of the to-be mail.

- Load the image to a temporary file with Win32 API call URLDownloadToFile
- Convert the image from PNG to GIF using IrfanView using calls to CreateProcess / WaitForSingleObject API functions
- Create a NotesDocument and insert the image as MIMEEntity.

This appears to work so far. I've yet to compose several images into one mail (basically, I'd like to see predictions from different sources in one mail) but I'm more or less optimistic that it will work.

<Flame>It's incredible that something so appearently simple is so complicated. For example, you appearently can't just add an image to a rich text item - either it's an attachment and not shown or it's an OLE object and takes ages to insert and load. So, one has to use the MIME classes to do it. This is ridiculous. </Flame>

Raputa - I had the impression that GetDocumentByURL includes the images found at the target URL and renders the doc to rich text. Well, it isn't working anyway so we don't need to waste time thinking about what it would do if it would function correctly.

I'm still open to suggestions (and ready to spend points) - does anybody see a simpler way to do this?

Jan

 

by: fulscherPosted on 2004-10-12 at 10:17:01ID: 12289387

Ok, the problem is more or less solved; by downloading the files and using the Notes MIME classes, I was able to put a mail together which contains all the images I want. It's a start.

Points will be split, since all of you contributed.

J

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...