Create Your Own PageGetter Using Outlook and C# Programming


PageGetter is one helpful feature that most corporate professionals would like to have. At times when certain Websites are blocked, or in the case of no internet connectivity, page getters serve a mammoth boon.

Well, this article does not compare itself to PageGetter's available in the market, this just overviews the use of the .NET Framework to build an easy one in less than an hour and serve yourself as "Page Getter" to your friends.

Please Note: This article assumes that you have an Outlook profile running on a server.


  • Microsoft ActiveX Data Objects 2.7 Library
  • Microsoft CDO for Windows 2000 Library (installed with Outlook)
  • Microsoft Outlook 11.0 Object Library
  • Microsoft Visual J# .NET Class Library


This application searches the Outlook Default Profile account for any emails that has a URL in the subject and the body of the email starting with the word "url" (this acts a filter). So any mails found with such a pattern, it checks for the validity of the URL requested and downloads the file in .mht format and zips and sends it to the user who requested it. If the URL requested is invalid, then it sends an email to the user saying it is a "bad url".

The application also runs itself on a specified interval (specified through the pageGetter.config file).

This application is a simple idea that can be enriched with WPF UI, WCF framework and much more. It uses .NET controls that come with Microsoft Visual Studio by default.


The application uses two other classes for its functioning.

  • Zipper.cs: Has methods to compress a file/directory, built using the MS Visual J# library , available in 1.1
  • Helper.cs: Methods to check a URL, download a file in .mht format, send mail, and are available here.

This article starts off with a reference to the Outlook 11.0 Library.

To date, the functionality of Outlook is exposed through a COM-based in-process server (msoutl.olb). When .NET developers wish to interact with these COM types, therefore, you will need to do so through the interoperability layer. Microsoft Corporation has already supplied an 'official' interop assembly (a.k.a., the primary interop assembly) which ships with Outlook 2003.

This assembly has been strongly named, and resides in the Global Assembly Cache under the name Microsoft.Office.Interop.Outlook.dll. To reference this assembly from Microsoft Visual Studio .NET 2003, access the COM tab from the "Add References" dialog and select "Microsoft Outlook 11.0 Object Library".

Figure 1

Outlook.Application   outAp  = new Outlook.Application(); Outlook.NameSpace   outNS    = outapp.GetNamespace("MAPI"); Outlook.MAPIFolder    MyBox   =  outNS.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);


And followed by a call to GetMailList() function which does the whole work.

Please note: The following message might appear as a custom made program is trying to access Outlook. Although intrusive to the end user, this behavior is by design. It is one of the security features built in 11.0. If there is any simple way of avoiding it other than using redemption, please let me know.

Figure 2

This function loops through all mails in the inbox, looking for mails that start with the word "url" in their body. In case of finding such a mail, it checks the URL, and if valid downloads the file in the .mht format using the SaveWebPageToMHTFile() that is present in the Helper Class itself.

System.Net.WebClient client = new System.Net.WebClient();
byte [] bytedata = client.DownloadData(url);

The above code downloads as normal htm files. Since .mht files are good in the sense, that they are downloaded with all supporting files (css, images etc) they are always a better option.

So we used the ADO and CDO objects to create a function SaveWebPageToMHTFile()...

//Saves the url to a Archive File (.mht)

public static bool SaveWebPageToMHTFile( string url, string filePath)
	CDO.Message		msg = new CDO.MessageClass(); 
	ADODB.Stream	stm = null ;
	msg.MimeFormatted =true;   
(url,CDO.CdoMHTMLFlags.cdoSuppressNone, "" ,"" );
	stm = msg.GetStream();

Since .mht files are naturally very big to their .htm counterparts, I thought zipping them would be handy.

The requested file is saved in a folder specified in the config file through the FileName parameter. Ensure that you write permission to this directory.

This application uses the Visual J# library that comes with .NET framework 1.1 to zip the file. Then zips and sends the zipped version to the requested user and keeps updating the listview on the main form for the status of the mails sent.

For the context menu on the listview, it just uses an image which launches the non rectangular about form.

The about form is created using the trivial way of achieving non-rectangular forms.

And the rest of the code is self-explanatory.

About the Author

Srinath M S

I would love to leave a footprint in this flat world


  • PageGetter: Where's the code?

    Posted by sysfrank on 06/21/2010 10:56am

    Where's the code?

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As the mobile enterprise marketplace expands and customer needs grow more diverse, Samsung recognizes that solution partners and developers play an essential role by continually innovating to meet their customers' needs. Samsung works to provide these developers and partners with the latest tools and resources needed to create these solutions. Read this program guide to learn how the Samsung Enterprise Alliance Program provides partners and developers with Samsung enterprise software development kits (SDKs) …

  • Lenovo recommends Windows 8 Pro. "I dropped my laptop getting out of the taxi." This probably sounds familiar to most IT professionals. If your employees are traveling, you know their devices are in for a rough go. Whether it's a trip to the conference room or a convention out of town, any time equipment leaves a user's desk it is at risk of being put into harm's way. Stay connected at all times, whether at the office or on the go, with agile, durable, and flexible devices like the Lenovo® …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date