Friday 9 December 2011

Opening Outlook with new e-mail from Asp.net

add Outlook reference through com
then include  " using Outlook = Microsoft.Office.Interop.Outlook;  " in header
use the following code for opening outlook with new email

code:

try
        {
            // Create the Outlook application.
            Outlook.Application oApp = new Outlook.Application();

            // Get the NameSpace and Logon information.
            Outlook.NameSpace oNS = oApp.GetNamespace("mapi");

            // Log on by using a dialog box to choose the profile.
            oNS.Logon("Outlook", "", true, true);

            // Alternate logon method that uses a specific profile.
            // TODO: If you use this logon method,
            //  change the profile name to an appropriate value.
            //oNS.Logon("YourValidProfile", Missing.Value, false, true);

            // Create a new mail item.
            Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);

            // Set the subject.
            oMsg.Subject = "Testing";

            // Set HTMLBody.
            String sHtml;
            sHtml = "<HTML>\n" +
               "<HEAD>\n" +
               "<TITLE>Sample GIF</TITLE>\n" +
               "</HEAD>\n" +
               "<BODY><P>\n" +
               "<h1><Font Color=Green>Testing</Font></h1></P>\n" +
               "<P>Testing Testing Testing Testing</P>\n" +
               "<P>Testing Testing Testing Testing</P>\n" +
               "</BODY>\n" +
               "</HTML>";
            oMsg.HTMLBody = sHtml;
          //  oMsg.Attachments.Add(OpenFile(@"C:\MyAttachmentFi.txt"), Outlook.OlAttachmentType.olByValue, Type.Missing, Type.Missing);
            //try for attachments sorry the above code is not working..
           

            // Add a recipient.
            Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
            // TODO: Change the recipient in the next line if necessary.
            Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add("emailid@mail.com");
           
         oRecip.Resolve();
           oMsg.Display(oMsg);  //code for display the outlook
            // Send.
      //    oMsg.Send();    //code for sending

            // Log off.
          oNS.Logoff();

            // Clean up.
            oRecip = null;
            oRecips = null;
            oMsg = null;
            oNS = null;
            oApp = null; 
        }

         // Simple error handling.
        catch (Exception ess)
        {
            Console.WriteLine("{0} Exception caught.", ess);
        } 


screen shot:


Thankyou..:)

Tuesday 22 November 2011

Remove underline from link button ?

#1 CSS
 .NoUnderLine
   {
      text-decoration: none;
   }
#2 HTML
 <asp:linkbutton id="lnkLogOut" Text="LOGOUT" runat="server" CssClass="NoUnderLine" />

Friday 11 November 2011

Javascript onBlur function

Desc: When you click on the textbox the value of textbox is cleared by using Javascript
method.
function doEmptytextbox(id, txtVal)
{
         var searchtext = document.getElementById(id).value;
          if (searchtext == txtVal) {
          document.getElementById(id).value = "";
          }
}

function dorestoretextbox(id, txtVal)
{
         var searchtext = document.getElementById(id);

          if (searchtext.value == "") {
          document.getElementById(id).value = txtVal;
          }
}

When TextBox is in Master Page!... code goes like this.

<asp:TextBox ID="txtNcid" runat="server" BackColor="White" ForeColor="Black" Text="(New)/Search"onblur = "return dorestoretextbox('ctl00_MainContent_txtNcid', '(New)/Search');" onclick="return doEmptytextbox('ctl00_MainContent_txtNcid', '(New)/Search');" Font-Bold="true"></asp:TextBox>

Friday 19 August 2011

How to Retrieve a DLL from the GAC


Step 1. Opend Command prompt
Step 2. Browse for GAC/GAC_32/GAC_MSIL Folder
    (C:\Window\assembly\GAC)
    <image>
Step 3. Each assembly have it own folder. So if you need to access the assembly
            Like eg: CrystalDecisions.Enterprise.Franework
    C:\Window\assembly\GAC>cd CrystalDecisions.Enterprise.Franework
step 4. C:\Window\assembly\GAC\CrystalDecisions.Enterprise.Franework>
    Once in the folder, you should see a subfolder for each version of the assembly in the GAC.
    C:\Window\assembly\GAC\CrystalDecisions.Enterprise.Franework>dir
    you can see sub folders in it like This:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\WINDOWS\assembly\GAC\CrystalDecisions.Enterprise.Framework\10.5.3700.0__692fb
ea5521e1304>dir
 Volume in drive C is TECLAB-4
 Volume Serial Number is 3844-D579

 Directory of C:\WINDOWS\assembly\GAC\CrystalDecisions.Enterprise.Framework\10.5
.3700.0__692fbea5521e1304

04/11/2009  02:47 AM    <DIR>          .
04/11/2009  02:47 AM    <DIR>          ..
04/11/2009  02:47 AM            45,056 CrystalDecisions.Enterprise.Framework.dll

04/11/2009  02:47 AM               229 __AssemblyInfo__.ini
               2 File(s)         45,285 bytes
               2 Dir(s)   5,783,031,808 bytes free
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
step 5. Now copy this dll to your prefred location using COPY or XCOPY Command.

 C:\WINDOWS\assembly\GAC\CrystalDecisions.Enterprise.Framework\10.5.3700.0__692fbea5521e1304>xcopy * \jeevandll
 C:CrystalDecisions.Enterprise.Framework.dll
 C:__AssemblyInfo__.ini
 2 File(s) copied

Thursday 11 August 2011

What is Abstraction

Abstraction :

        Abstraction is “the process of identifying common patterns that have systematic variations;
        an abstraction represents the common pattern and provides a means for specifying which variation to use”
(OR)
         Abstraction is the representation of only the essential features of an object

Example Description:(Abstraction and Encapsulation)

#1    Consider an example from the programmer’s view who wants to allow the user to add items to a form/list.
    The user only needs to click a button to add an item (Abstraction).
                The mechanism of how the item is added to the list is not essential for him (Encapsulation)
#2    Example You r driving a car. U does not need to know the internal working of the engine or the way gear changes work,
    to be able to drive the car (Encapsulation). Instead, U needs to know things such as how much turning the steering wheel
    needs, etc... (Abstraction).

Abstract Class in C Sharp

Abstract Class in C Sharp:

    A Class is declared with Abstract keyword, and which is can not be instantiated and they are frequently either partially implemented,
    or not at all implemented..
    It can be used as a Super Class or Base Class for other classes.
    Its Implementation is done only in sub classes
    A Class can inherit one abstract class and must override all its abstract methods etc.
Example:

public abstract class WashingMachine
{
   public WashingMachine()            //Implemented method
   {
      // Code to initialize the class goes here.
   }

   abstract public void Wash();            //Un Implemented method
   abstract public void Rinse(int loadSize);    //Un Implemented method
   abstract public long Spin(int speed);        //Un Implemented method
}

implementation of each abstract (Must Override) method in that class, and each implemented method must
receive the same number and type of arguments, and have the same return value,
as the method specified in the abstract class

public class MyWashingMachine : WashingMachine
{
   public MyWashingMachine()
   { 
      // Initialization code goes here.   
   }

   override public void Wash()
   {
      // Wash code goes here.
   }

   override public void Rinse(int loadSize)
   {
      // Rinse code goes here.
   }

   override public long Spin(int speed)
   {
      // Spin code goes here.
   }
}

Wednesday 10 August 2011

Polymorphism in C sharp

Polymorphism in C sharp:

The word Polymorphism means MANY FORMS.
Ability to show more than one form.

Polymorphism is of  TWO types;
1. Complietime polymorphism (nothing but Method Overloading)
    In Method Overloading method takes different input parameters and it do different tasks.
    It's also called early binding.
Example:

class Program

    {

        public class ShapeInformation

        {

            public void Area(float r) // With 1 parameter
            {

                float a = (float)3.14 * r;
                Console.WriteLine("Area of a circle:",a);
            }

            public void Area(float l, float b) // With 2 parameters
            {

                float x = (float)l* b;
                Console.WriteLine("Area of a rectangle: {0}",x);
            }

            public void Area(float a, float b, float c) //3 parameters
            {
                float s = (float)(a*b*c)/2;
                Console.WriteLine("Area of a circle: {0}", s);
            }

        }



        static void Main(string[] args)
        {

            ShapeInformation SI = new ShapeInformation();

            SI.Area(2.0f);
            SI.Area(20.0f,30.0f);
            SI.Area(2.0f,3.0f,4.0f);
            Console.ReadLine();
        }

    }

Note:
        While method overloading overloads must be in different signature,
         name is same and the number of parameters should be varies.

2. Runtime polymorphism (nothing but Method Overriding)
    It's Done using in inheritance and virtual functions. Mthod overriding is called Runtime polymorphism
    It's also called late binding.
    when child class declares a method that has the same type arguments as a method declared by one of its baseclass
Example:
public class ParentObject
{
    public virtual void Draw()
    {
    Console.WriteLine("I am a drawing object:Parent.");
    }
}
public class Child: ParentObject
{
    public override void Draw() //Draw is a base class name overriding in child class
    {
    Console.WriteLine("I am a Triangle:Child.");
    }
}


public class ShapeDemo
{
    public static void Main()
    {
    ParentObject ParentObj = new child();
    ParentObj.Draw();
   
}

Tuesday 9 August 2011

Encapsulation in C Sharp

Encapsulation: Means protect or prevent data from corruption (Nothing but Hiding the data ).
Example With help of Properties:
using System;
public class Grossary
{
    private string item;

    public string Item
    {
     get{ return item; }
     set { item=Value; }
    }
}

Public Class GrossaryMain
{
    public static int Main(string[] args)
    {
    Item Id=new Item();
    id.item="Sugar";
    Console.Writeline("item :{0}",id.item);
    return 0;
    }
}

OutPut :Sugar.
Description:
We can not access the private data outside of the Grossary() class.
so we modified it with help of properties get, set by using method Item().

The above Properties Get is used to return the value.
             Set is used to Set the Value.

Thursday 4 August 2011

Passing Parameter to Crystal Report

   ReportDocument report_crp;
    CrystalReportViewer crv;

crv = new CrystalReportViewer();
            report_crp = new ReportDocument();
            report_crp.Load(Server.MapPath("reportname"));
            #region Parameters passing to rpt file
            //  Passing parametrs
            ParameterValues pvs = new ParameterValues();
            ParameterDiscreteValue pdsv = new ParameterDiscreteValue();
            ParameterFieldDefinitions pfds;
            ParameterFieldDefinition pfd;
            pfds = report_crp.DataDefinition.ParameterFields;
            pfd = pfds["@Param1"];
            pvs = pfd.CurrentValues;
            pdsv = new ParameterDiscreteValue();
            pdsv.Value = Request.QueryString["Param1"].ToString();// "11/06/2010";
            pvs.Add(pdsv);
            pfd.ApplyCurrentValues(pvs);
            pfds = report_crp.DataDefinition.ParameterFields;
            pfd = pfds["@Param2"];
            pvs = pfd.CurrentValues;
            pdsv = new ParameterDiscreteValue();
            pdsv.Value = Request.QueryString["Param2"].ToString();//"7373";
            pvs.Add(pdsv);
            pfd.ApplyCurrentValues(pvs);
            pfds = report_crp.DataDefinition.ParameterFields;
            pfd = pfds["@Param3"];
            pvs = pfd.CurrentValues;
            pdsv = new ParameterDiscreteValue();
            pdsv.Value = Request.QueryString["Param3"].ToString();//"M01";
            pvs.Add(pdsv);
            pfd.ApplyCurrentValues(pvs);
            //End Passing paramentes
            #endregion
            crv.ReportSource = report_crp;
            crv.HasExportButton = true;
            crv.HasToggleGroupTreeButton = true;
            crv.DisplayGroupTree = true;
            crv.HasCrystalLogo = true;
            crv.HasDrillUpButton = true;
            crv.HasViewList = true;
            crv.HasPrintButton = true;

Friday 15 April 2011

Add Image Coloumn to the Crystal Report

Note: While Using with XSD...

#1. Add new column to xsd with name : image_stream.

#2.Set Column Data type is System.Byte[].

#3.Image Field is ready in Crystal Report Field Explorer.

#4.Drag and drop that field to Crystal Report desgine page.

Thursday 14 April 2011

If Condition In HTML Code

Q# How to Use "IF" Condition in HTML Code

Solution:

  <table id="Hide">
      <tr>
            <td valign="bottom">
                     <% if (Condition){ %>
                                Expression
                       <% }  %>
              </td>
       </tr>
  </table>