Thursday, December 23, 2010

Working in Work Flow

OMG,

Hey Flocks doing a long research in windows workflow foundation at last found some useful stuffs to update finally I won the game designed a simple workflow. Flocks dn't do anything jst follow these simple step yo knw wat I m in very urge to finish the blog so no image can be posted so excuse me for tat


Use:

The example demonstrate running WF in ASP.NET site. The WF will function as a number divider.
Input number1 and number2 WF will calculate number1/number2.

To run this sample project:
1. Run in Visual Studio 2008. After loading ASPNETSite4WF, right click Default.aspx and click
"View in Browser".
2. Run In IIS. Copy ASPNETSite4WF project to a IIS Virtual Directory. copy CSWFInASPNET.dll
to bin folder under ASPNETSIte4WF project folder. then , access to Default page in IE.


/////////////////////////////////////////////////////////////////////////////////////////////
Project Dependency

ASPNETSite4WF -> CSWFInASPNET


/////////////////////////////////////////////////////////////////////////////////////////////
Creation:

To create this sample from scratch, follow these steps.

step 1. Create a Sequential Workflow Library named CSWFInASPNET, name Solution as
CSWFInASPNET too.
step 2. In Project CSWFInASPNET, delete defiantly created Workflow1 and add a new cs
file named DivideNumberWF.cs to this project. and copy the following code to DivideNumberWF.cs
     using System; 
     using System.Collections.Generic; 
     using System.Workflow.Activities; 

     class DivideNumberWF : SequentialWorkflowActivity{ 
         private DelayActivity delayActivity1; 
         private CodeActivity codeActivity1; 

         public double Number1 { getset; } 
         public double Number2 { getset; } 
         public Double Result { getset; } 

         public DivideNumberWF(){ 
             InitializeComponent(); 
         } 

         [System.Diagnostics.DebuggerNonUserCode
         private void InitializeComponent(){ 
             this.CanModifyActivities = true
             this.codeActivity1 = new System.Workflow.Activities.CodeActivity(); 
             this.delayActivity1 = new System.Workflow.Activities.DelayActivity(); 

             // codeActivity1 
             this.codeActivity1.Name = "codeActivity1"
             this.codeActivity1.ExecuteCode += new System.EventHandler(this.codeActivity1_ExecuteCode); 

             // delayActivity1 
             this.delayActivity1.Name = "delayActivity1"
             this.delayActivity1.TimeoutDuration = System.TimeSpan.Parse("00:00:10"); 

             // DivideNumberWF 
             this.Activities.Add(this.delayActivity1); 
             this.Activities.Add(this.codeActivity1); 
             this.Name = "DivideNumberWF"
             this.CanModifyActivities = false
        } 

        private void codeActivity1_ExecuteCode(object sender, EventArgs e) { 
             if (Number2 != 0){ 
                  Result = Number1 / Number2; 
             }else
                  Result = 0;
             } 
         } 
    } 

step 3. Add a ASP.NET Web Application to CSWFInASPNET Solution. Name the Web Application
as ASPNETSite4WF. Add reference to CSWFInASPNET project; also add reference to
System.Workflow.Activities; System.Workflow.ComonentModel; System.Workflow.Runtime
step 4. In ASPNETSiteWF, add Global.asax file, and add the following code to Application_Start method:
     WorkflowRuntime workflowRuntime = new WorkflowRuntime(); 
      // Add ManualWorkflowSchedulerService 
     ManualWorkflowSchedulerService scheduler = new ManualWorkflowSchedulerService(true); 
     workflowRuntime.AddService(scheduler);

     Application["WorkflowRuntime"] = workflowRuntime;
Next, add following code to Application_End method:
      WorkflowRuntime workflowRuntime = Application["WorkflowRuntime"as WorkflowRuntime
     workflowRuntime.StopRuntime(); 
Then, use VS to fix reference.
step 5. Add the following code to Default.aspx.cs file    

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Workflow.Runtime;
    using System.Workflow.Runtime.Hosting;
    using System.Threading;
    using CSWFInASPNET;
    namespace ASPNETSite4WF{
        public partial class _Default : System.Web.UI.Page{
             WorkflowRuntime workflowRuntime;
             WorkflowInstance wfInstance;
             Guid instanceId;
             AutoResetEvent autoWaithandler = new AutoResetEvent(false);
             double dividendValue;
             double divisorValue;
             protected void Page_Load(object sender, EventArgs e){}
             protected void Button1_Click(object sender, EventArgs e){
                 workflowRuntime = Application["WorkflowRuntime"] as WorkflowRuntime;
                 //retrieve the scheduler that is used to execute workflows
                 ManualWorkflowSchedulerService scheduler = workflowRuntime.GetService(typeof(ManualWorkflowSchedulerService)) as ManualWorkflowSchedulerService;
                 //handle the WorkflowCompleted event in order to
                 //retrieve the output parameters from the completed workflow
                 workflowRuntime.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(workflowRuntime_WorkflowCompleted);
                 Double.TryParse(TextBox3.Text, out dividendValue);
                 Double.TryParse(TextBox2.Text, out divisorValue);
                 //pass the input parameters to the workflow
                 Dictionarying, Object> wfArguments = new Dictionary<string, object>();
                 wfArguments.Add("Number1", dividendValue);
                 wfArguments.Add("Number2", divisorValue);

                 //create and start the workflow
                 WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(DivideNumberWF), wfArguments);
                 instance.Start();
                 //execute the workflow synchronously on our thread
                 scheduler.RunWorkflow(instance.InstanceId);
                 autoWaithandler.WaitOne();
            }

            void workflowRuntime_WorkflowCompleted(object sender, WorkflowCompletedEventArgs e){
                //get the result from the workflow
                if (e.OutputParameters.ContainsKey("Result")){
                    Double quotientValue = (Double)e.OutputParameters["Result"];
                    TextBox4.Text = quotientValue.ToString();
                }
                autoWaithandler.Set();

            }

        }

    } 


Use VS to fix references .

step 6. Copy the following code to Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ASPNETSite4WF._Default" %> 

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml" > 
<head id="Head1" runat="server"> 
<title>title> 
head> 
<body> 
<form id="form2" runat="server"> 
<div> 
Number1<asp:TextBox ID="TextBox3" runat="server">asp:TextBox> 
<br /> 
Number2<asp:TextBox ID="TextBox2" runat="server">asp:TextBox> 
<br /> 
<asp:Button ID="Button1" runat="server" Text="Divide" 
onclick="Button1_Click" /> 
<br /> 
<br /> 
Result     
<asp:TextBox ID="TextBox4" runat="server">asp:TextBox> 
div> 
form> 
body> 
html






Happy Programming

Tuesday, November 23, 2010

Button that will call Outlook express

Hey all,
      Just few days back I tried to implement the mail transferring with .NET I came across some solutions

1) How to send the mail that will automatically call the outlook express on click button finally ?

Here is the solution


               System.Diagnostics.Process.Start("Outlook");
                ProcessStartInfo startInfo = new ProcessStartInfo("Outlook.exe"); // Open Outlook express
                string admin = "mparamasivan@newtglobal.com";
                startInfo.FileName = "mailto:" + admin + "?subject=Applying for Leave" + "&cc=" + offemail + "&body=" + Reason.Text; //Formated mail
              
                Process.Start(startInfo);


2) Through SMTP configuration via g-mail


System.Net.Mail.MailMessage toSend = new System.Net.Mail.MailMessage("from email ID", "To email ID", "Subject", "messageBody");
        SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
        smtp.EnableSsl = true;
        System.Net.NetworkCredential mailAuthentication = new System.Net.NetworkCredential("some gmail id @gmail.com", "password of it");
        smtp.Credentials = mailAuthentication;
        smtp.Send(toSend);


Hope the information vl save ur time.

Happy Coding ;)

Wednesday, November 10, 2010

Select Date with leaving Weekend in Asp.Net

Hey All,
     For Past week I m worrying abt rendering the day counts in ASP.Net jst now found the solution .
For Example I vl let yo knw the scenario if I want to prepare leave form hence I got to design a calender with start date and end date to it what I m going to do just give yo the piece of code where weekend will be neg lated in the coding so when ever yo come across this scenario yo vl thank to me ...:-)


public void checkmonth()
    {
        TimeSpan timespan = Convert.ToDateTime(cal2).Subtract(Convert.ToDateTime(cal1));
        DateTime date1 = Convert.ToDateTime(cal1);
        DateTime date2 = Convert.ToDateTime(cal2);
        //NoOfDays.Text = Convert.ToString(timespan.Days + 1);
        long        wholeWeeks = ((long)Math.Round(Math.Floor(timespan.TotalDays))) / 7;
   DateTime    dateCount  = date1.AddDays(wholeWeeks * 7);
   int         endDays    = 0;


        
   while (dateCount.Date <= date2.Date)
   {
      switch (dateCount.DayOfWeek)
      {
         case DayOfWeek.Saturday:
         case DayOfWeek.Sunday:
            break;
         default:
            endDays++;
            break;
         }
         dateCount = dateCount.AddDays(1);
   }
   NoOfDays.Text=Convert.ToString(wholeWeeks * 5 + endDays);

            }

Happy Coding

Wednesday, November 3, 2010

What if Bill Gates dies









Well, Bill,” said God, “I’m really confused on this one. I’m not sure whether to send you to Heaven or Hell! After all, you helped society enormously by putting a computer in almost every home in the world and yet you created that ghastly Windows. I’m going to do something I’ve never done before. I’m going to let you decide where you want to go!”
Mr. Gates replied, “Well, thanks, Lord. What’s the difference between the two?”
God said, “You can take a peek at both places briefly if it will help you decide. Shall we look at Hell first?” “Sure!” said Bill. “Let’s go!”
Bill was amazed! He saw a clean, white sandy beach with clear waters. There were thousands of beautiful women running around, playing in the water, laughing and frolicking about.
The sun was shining and the temperature was just perfect!
Bill said, “This is great! If this is Hell, I can’t wait to see Heaven!”
To which God replied, “Let’s go!” and off they went. Bill saw puffy white clouds in a beautiful blue sky with angels drifting about playing harps and singing.
It was nice, but surely not as enticing as Hell. Mr. Gates thought for only a brief moment and rendered his decision.
“God, I do believe I would like to go to Hell.”
“As you desire,” said God.
Two weeks later, God decided to check up on the late billionaire to see how things were going. He found Bill shackled to a wall, screaming among the hot flames in a dark cave. He was being burned and tortured by demons.
“How ya doin’, Bill?” asked God. Bill responded with anguish and despair.
“This is awful! This is not what I expected at all! What happened to the beach and the beautiful women playing in the water?”
“Oh, THAT!” said God.
“That was the screen saver”….!! !!!!!!!

Wednesday, October 27, 2010

Export to Excel

Hey flocks Just now I faced a problem in converting a grid view to Excel. Just now I came out with a solution
First step is add reference's with the excel by right click on the solution explorer and click on add reference also yo will find out .net, com tabs click on tab then scroll down for some distance yo vl find the microsoft Execel some thing jst select tat 
Just add a grid and input all the values as your wish the next thing you got to do is
hav a button belove the grid nd on button click even try following code seriously tis vl work out

protected void Button1_Click(object sender, EventArgs e)
    {
        Microsoft.Office.Interop.Excel._Application app = new Microsoft.Office.Interop.Excel.Application();


        // creating new WorkBook within Excel application
        Microsoft.Office.Interop.Excel._Workbook workbook = app.Workbooks.Add(Type.Missing);


        // creating new Excelsheet in workbook
        Microsoft.Office.Interop.Excel._Worksheet worksheet = null;
      
        // see the excel sheet behind the program
        app.Visible = true;

        // get the reference of first sheet. By default its name is Sheet1.
        // store its reference to worksheet
        worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Sheets["Sheet1"];
        worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.ActiveSheet;

        // changing the name of active sheet
        worksheet.Name = "Exported from gridview";


        // storing header part in Excel
        for (int i = 1; i < dataGridView1.Columns.Count + 1; i++)
        {
            worksheet.Cells[1, i] = dataGridView1.Columns[i - 1].HeaderText;
        }



        // storing Each row and column value to excel sheet
        for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
        {
            for (int j = 0; j < dataGridView1.Columns.Count; j++)
            {
                worksheet.Cells[i + 2, j + 1] = dataGridView1.Rows[i].Cells[j].Text.ToString();
            }
        }

        workbook.SaveAs(@"D:\aa.xsl", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
        // save the application
        //workbook.SaveAs("c:\\output.xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

        // Exit from the application
        app.Quit();
    }

Sunday, October 10, 2010

Inserting and Retrieving Image using LINQ to SQL from ASP.Net Application

Inserting and Retrieving Image using LINQ to SQL from ASP.Net Application

Objective
In this article, I am going to show you
1. How to insert an image from ASP.Net application to SQL Server using LINQ to SQL.
2. How to retrieve image from SQL Server data base using LINQ to SQL and display to an Image control.
Block Diagram of solution
clip_image002
Description of table
For my purpose, I have created a table called ImageTable.
clip_image003
1. Id is primary key.
2. Name column will contain name of the image file.
3. FileSource column will contain binary of image. Type of this column is image.
Create ASP.Net Web Application
Open visual studio and from File menu select New Project and then from Web tab select new web application. Give meaningful name to your web application.
Create DBML file using LINQ to SQL class.
For detail description on how to use LINQ to SQL class read HERE
1. Right click on the project and select add new item.
2. From DATA tab select LINQ to SQL Class.
3. On design surface select server explorer.
4. In server explorer and add new connection.
5. Give database server name and select database.
6. Dragged the table on the design surface.
Once all the steps done, you will have a dbml file created.
Design the page
1. I have dragged one FileUpload control and a button for upload purpose.
2. One text box. In this text box user will enter Id of the image to be fetched.
3. One button to fetch the image from database.
4. One Image control to display image from database.
Default.aspx
clip_image005
Saving image in table
On click event of Button 1 Image upload will be done.
clip_image007
In this code
1. First checking whether FileUplad control contains file or not.
2. Saving the file name in a string variable.
3. Reading file content in Byte array.
4. Then converting Byte array in Binary Object.
5. Creating instance of data context class.
6. Creating instance of ImageTable class using object initializer. Passing Id as hard coded value. Name as file name and FileSource as binary object.
Retrieving Image from table
On click event of button2 Image will be fetched of a particular Id. Image Id will be given by user in text box.
clip_image009
In above code, I am calling a generic HTTP handler. As query string value from textbox1 is appended to the URL of HTTP handler. To add HTTP handler, right click on project and add new item. Then select generic handler from web tab.
clip_image011
In above code,
1. Reading query string in a variable.
2. Calling a function returning ShowEmpImage returning Stream.
3. In ShowEmpImage , creating object DataContext class .
4. Using LINQ fetching a particular raw from table of a particular ID.
5. Converting image column in memory stream. In this case FileSource column is containing image.
6. Converting stream into byte array.
7. Reading byte array in series of integer.
8. Using Output stream writing the integer sequence.
Running application

output1Output2
 Output3
For your reference entire source code is given below ,
Default.aspx.cs
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Web;
    5 using System.Web.UI;
    6 using System.Web.UI.WebControls;
    7 using System.Data.Linq;
    8 using System.IO;
    9 
   10 namespace uploadingImageusingLInqtoSQl
   11 {
   12     public partial class _Default : System.Web.UI.Page
   13     {
   14         protected void Page_Load(object sender,EventArgs e)
   15         {
   16 
   17         }
   18 
   19         protected void Button1_Click(object sender,EventArgs e)
   20         {
   21             if (FileUpload1.HasFile && FileUpload1.PostedFile.ContentLength > 0)
   22             {
   23                 string fileName = FileUpload1.FileName;           
   24 
   25                 byte[] fileByte = FileUpload1.FileBytes;
   26                 Binary binaryObj = newBinary(fileByte);
   27                 DataClasses1DataContext context =new DataClasses1DataContext();
   28                 context.ImageTables.InsertOnSubmit(
   29                     new ImageTable { Id = “xyz”,
   30                         Name = fileName,
   31                         FileSource = binaryObj });
   32                 context.SubmitChanges();
   33 
   34 
   35             }
   36         }
   37 
   38         protected void Button2_Click(object sender,EventArgs e)
   39         {
   40 
   41 
   42             Image1.ImageUrl = “~/MyPhoto.ashx?Id=”+TextBox1.Text;
   43 
   44         }
   45 
   46 
   47     }
   48 }
   49 

MyPhoto.ashx.cs

    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Web;
    5 using System.IO;
    6 using System.Web.UI;
    7 using System.Web.UI.WebControls;
    8 
    9 
   10 namespace uploadingImageusingLInqtoSQl
   11 {
   12     /// 
   13     /// Summary description for MyPhoto
   14     /// 
   15     public class MyPhoto : IHttpHandler
   16     {
   17 
   18         public void ProcessRequest(HttpContextcontext)
   19         {
   20 
   21             string id = context.Request.QueryString["Id"];
   22             context.Response.ContentType =“image/jpeg”;
   23             Stream strm = ShowEmpImage(id);
   24             byte[] buffer = new byte[4096];
   25             int byteSeq = strm.Read(buffer, 0, 4096);
   26             while (byteSeq > 0)
   27             {
   28                 context.Response.OutputStream.Write(buffer, 0, byteSeq);
   29                 byteSeq = strm.Read(buffer, 0, 4096);
   30             }  
   31         }
   32 
   33         public Stream ShowEmpImage(string id)
   34         {
   35             DataClasses1DataContext context1 = newDataClasses1DataContext();
   36             var r = (from a in context1.ImageTableswhere a.Id == id select a).First();
   37             return newMemoryStream(r.FileSource.ToArray());         
   38 
   39         }
   40         public bool IsReusable
   41         {
   42             get
   43             {
   44                 return false;
   45             }
   46         }
   47     }
   48 }

Thanks for reading. I hope this post is useful. Happy Coding.

Friday, October 8, 2010

Add User Login with in a min

Flocks 2day I tried to add membership login with ASP.Net can yo believe it reducing our work with in some mins.Here I vl go through How I did !
Here there are some 2 things one is for login and another is for new account creation. I am sure tat yo can go to administrator web site so that yo can make some edit in security like adding roles for each user and access privilages.
 Also to redirect from one page to another a set of code got to be followed
try 
                { 
                    if (Membership.ValidateUser(Login1.UserName,Login1.Password)) 
                   { 
                       //Authenticated successful, redirect to the page specified in web.config as DefaultPage 
                       Response.Redirect(@"~/Personal/Default.aspx");
                    } 
     
                    else 
                   { 
                       //Authenticated failed, redirect to LoginError.aspx 
                       Response.Redirect("~/Loginerror.aspx"); 
                    } 
               } 
    
               catch (Exception ex) 
               {
                   Console.WriteLine("invalid Login");
               }  

Hope for the happy coding for any elaboration work ping me. ;)

Sunday, October 3, 2010

What will be If computer throws error Like this

For few days I am working on some projects and going through some technology. I am not wonder I am getting so many errors while compiling or run-time because it usually happens but I wonder how it will be if the errors or so funny like vadivelu's dialog and How interesting it will be to work

May be : (if..else)  Thrisha illana Divya

(Memory exception) : Soppa over ra kanna Katuthe

(Same error reap ting ) : Nee yaaru kitta paysikittu irrukaynu theriyuma? Sekar ngara oru TERROR kitta


(compile Time error) :Huh.. yennaku body strong basement weeeku


(Successful Compilation or mild error) : Don't worry.. Be gaaapy


(If looking for some other resources): Helloo.. Prabha wine shop ownerungala? Kadaiya.. yeppo saar tharapeenga?


(Un-Rectify error) : romba nallavanu enna pathu sollitanmaaaaa...


I wish here by adding some of ma view your invitations are welcomed

Sunday, July 25, 2010

Get Meebo Bar in ur blog/ Web Site

Few days Ago I came across a Site Which I found very attractive which is almost similar to old fb status bar I love the sharing option in it. So I looked in to it nd found at last with meebo jst create account for free and its also easy to edit.


  1. Javascript: Include the following HTML/javascript on your page immediately following the body tag:

body>
script type="text/javascript">
if (typeof Meebo == 'undefined') {
 var M=Meebo=function(){(M._=M._||[]).push(arguments)},w=window,a='addEventListener',b='attachEvent',c='load',
 d=function(){M.T(c);M(c)},z=M.$={0:+new Date};
 M.T=function(a){z[a]=+new Date-z[0]};if(w[a]){w[a](c,d,false)}else{w[b]('on'+c,d)};M.v=3;
 (function(_){var d=document,b=d.body,c;if(!b){c=arguments.callee;
 return setTimeout(function(){c(_)},100)}var a='appendChild',c='createElement',
 m=b.insertBefore(d[c]('div'),b.firstChild),n=m[a](d[c]('m')),i=d[c]('iframe');
 m.style.display='none';m.id='meebo';i.frameBorder="0";n[a](i).id="meebo-iframe";
 function s(){return[''].join('')}try{
 d=i.contentWindow.document.open();d.write(s());d.close()}catch(e){
 _.d=d.domain;i['sr'+'c']='javascript:d=document.open();d.write("'+s().replace(/"/g,'\\"')+'");d.close();'}M.T(1)})
    ({ network: 'santhosh_lu09qe', stage: false });    
}




2.Javascript: Include the following HTML/javascript at the bottom of your page, just prior to the close body tag:



script type="text/javascript">
    Meebo('domReady');
/script>
/body>






The Simplest way to add hope this Will be Useful enjoy.

Friday, July 23, 2010

Funny :)

1. Once, all villagers decided to pray for rain. On the day of prayer all the People gathered, but only one boy came with an umbrella…  
THAT’S FAITH.
2. When you throw a baby in the air, she laughs because she knows you will  catch her…
THAT’S TRUST.
3.Every night we go to bed, without any assurance  of being alive the next Morning. But still we set the alarm to wake us up…
THAT’S HOPE.
4. We plan big things for tomorrow in spite of  zero knowledge of the future, or having any  certainty of uncertainties. ..
THAT’S CONFIDENCE.
5. We see the world suffering. We know there is a possibility of same or similar things  happening to us. But still we get married!!!!!!……………….

THAT’S OVER CONFIDENCE

Wednesday, June 30, 2010

Mailing with PHP

Few days before I m in a situation to send the email through my PHP program I found it might be very difficult but atlast find the simple solution here I vl tell yo how I did all those in steps.
Step 1: Install php mailer any version (before that yo have to config your Lamp/Wamp)
Step 2: Use this code for sending and receiving of mail
include("/var/www/PHPMailer_v2.0.4/class.phpmailer.php"); include("/var/www/PHPMailer_v2.0.4/class.smtp.php");
$mail             = new PHPMailer();     $body             = $mail->getFile("location of file to attach");// You can attach text file or HTML over here
$body             = eregi_replace("[\]",'',$body);
$mail->IsSMTP(); 
$mail->SMTPAuth   = true;                  // enable SMTP authentication 
$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier 
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server 
$mail->Port       = 465;                   // set the SMTP port for the GMAIL server  
$mail->Username   = "xx@gmail.com";  // GMAIL username
 $mail->Password   = "xx";            // GMAIL password 

 $mail->AddReplyTo("to replay @gmail.com","Name "); 
 $mail->From       = "From gmail@gmail.com"; 
$mail->FromName   = "Name";
  $mail->Subject    = "Conformation was done";  
$mail->Body       = "Hi,This is the HTML BODYWelcome";            //HTML Body
 $mail->Altbody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
 $mail->WordWrap   = 50; // set word wrap 
 $mail->MsgHTML($body); 
 $mail->AddAddress("to_address@gmail.com", First name);// Add to address over Here 
 $mail->AddAttachment("/var/www/header.gif");             // attachment 
 $mail->IsHTML(true); // send as HTML
  if(!$mail->Send()) 
{   
echo "Mailer Error: " . $mail->ErrorInfo;
 }
 else {  echo "Message sent!";  } 
 ?>
Hope this will be very use full.. I used it gained very much.. Try it by yourself...