Skip to main content

Posts

Showing posts from May, 2013

GOOGLE MAPS API sample program

SAMPLE CLASS TO GET DISTANCE BETWEEN TWO GEO PLACES AND AND RETRIEVE OTHER DETAILS by USING GOOGLE MAPS API

/*just uploaded without explanations ,if someone needs more contact me*/



using System.IO;
using System.Net;
using System.Xml;

/*
* author : @kushanlahiru
*
*
how to use the class
*
*first setValues(string destination, string origin)
*second calculateDistance()
*third get values distance or travel details
*/
namespace Data
{
public class GoogleDistance
{

private string destination;

private string origin;

private string distance;

private string travelDetail;
GoogleDistance() //constructor
{
destination="";
origin="";
distance="";
travelDetail="";
}
public string getTravelDetail()
{
return travelDetail;
}



public string getDistance()
{
return distance;
}



public void setValues(string destination, string origin)
{
this.destination = destination;
this.origin = origin;
}



public void calculateDistance()
{

string xmlResult = null;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("…

Simplest way to send email from your C# (ASP.net) application

<1> IMPORT LIBRARIES >> TO FORM(or ASPX page ) & CLASS 
using System.Net.Mail;
<2>INCLUDE CLASS BELOW 
class sendmail
{
public void testmail(string to,string subject,string body)
{
try
{
string To=to;
string sub=subject ;
string Body=body ;
MailMessage mail = new MailMessage();

SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");

mail.From = new MailAddress("absccd@gmail.com");

// email adress that i have created on gmail

// or you can use any mail server such as yahoo,aol,msn,and so on

mail.To.Add(To);

mail.Subject = sub;

mail.Body = Body;

SmtpServer.Port = 587;

SmtpServer.Credentials = new System.Net.NetworkCredential("userNAme", "Password");

//enter uname and pwd of email address you want to send email from

SmtpServer.EnableSsl = true;

SmtpServer.Send(mail);

MessageBox.Show("mail Sent successfully");

}

catch (Exception ex)
{

MessageBox.Show(ex.ToString());

}

}

}
<3>CREATE OBJECTS FROM THAT(in the form or page) and USE IT
sendmail obj…