Archive for 2008

HtmlUnit: A Simple Example: Check Yahoo Email

Tuesday, August 26th, 2008 Posted in Java | Comments Off

by Muneeb Ahmad package com.examples.htmlunit; import java.io.IOException; import java.net.URL; import java.util.List; import com.gargoylesoftware.htmlunit.BrowserVersion; import com.gargoylesoftware.htmlunit.Page; import com.gargoylesoftware.htmlunit.RefreshHandler; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.HtmlAnchor; import com.gargoylesoftware.htmlunit.html.HtmlForm; import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.gargoylesoftware.htmlunit.html.HtmlTable; import com.gargoylesoftware.htmlunit.html.HtmlTableRow; public class YahooMail { public static void main(String[] args) throws Exception { // Create and initialize WebClient ... Read more..

Get URL Response

Friday, July 18th, 2008 Posted in .NET/C# | Comments Off

public string GetSiteContents(string url) { StringBuilder sb = new StringBuilder(); byte[] buf = new byte[8192]; HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url); HttpWebResponse response = (HttpWebResponse) request.GetResponse(); Stream resStream = response.GetResponseStream(); string tempString = null; int count ... Read more..

Cookies

Friday, July 18th, 2008 Posted in .NET/C# | Comments Off

private void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { if (Request.Cookies["MuneebCookies"]!=null) { HttpCookie httpCookie = Request.Cookies["MuneebCookies"]; TextBox1.Text = httpCookie["FirstName"]; TextBox2.Text = httpCookie["LastName"]; } } } private void Button1_Click(object sender, System.EventArgs e) { HttpCookie httpCookie = new HttpCookie("MuneebCookies"); httpCookie.Values.Add("FirstName", TextBox1.Text); httpCookie.Values.Add("LastName", TextBox2.Text); httpCookie.Expires = DateTime.Now.AddHours(2); // ... Read more..

SMTP Mail

Friday, July 18th, 2008 Posted in .NET/C# | Comments Off

using System; using System.Web.Mail; namespace ConsoleApplication1 { class Class1 { [STAThread] static void Main(string[] args) { MailMessage Message = new MailMessage(); Message.To = "to_address@domain.com"; Message.From = "from_address@domain.com"; Message.Subject = "test1"; Message.Body = "test1"; try { Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1); Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "muneebsa"); Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "you03ahm"); Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 2); Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", "smtp.sbcglobal.yahoo.com"); Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", ... Read more..

Simple Database Access

Friday, July 18th, 2008 Posted in .NET/C# | Comments Off

string connectionString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=test;USER=root;PASSWORD=mypassword;OPTION=3;"; IDbConnection conn = new OdbcConnection(connectionString); conn.Open(); IDbCommand command = new OdbcCommand("select UserID, FirstName from Users"); command.Connection = conn; IDataReader reader = command.ExecuteReader(); while (reader.Read()) { string userID = (string) reader["UserID"]; string firstName ... Read more..

Send Email using SmartMail

Friday, July 18th, 2008 Posted in ASP | Comments Off

Read more..

Send Mail using JMail

Friday, July 18th, 2008 Posted in ASP | Comments Off

Read more..

Display Files in a Folder

Friday, July 18th, 2008 Posted in ASP | Comments Off

Document List Read more..

Read File Contents

Friday, July 18th, 2008 Posted in ASP | Comments Off

Read more..

Server Variables

Friday, July 18th, 2008 Posted in ASP | Comments Off

Read more..