My Linux Stuff - Complete Blog For Linux Articles

My Linux Stuff - Complete Blog For Linux Articles

A Website For Complete Linux OS,Step by Step linux Installtion, Linux Tips and Tricks and Linux Stuff and so on... Connect and sharing here....

TOP 50 ENGINEERING COLLEGES IN INDIA 2014

TOP 50 ENGINEERING COLLEGES IN INDIA 2014

This below survey was taken many form many colleges in India. These Top 50 Engineering Colleges in India have Good Infrastructure, Good Environment, Educations , Staff, Placement , Research Activities and other Facilities are good.

Top 10 Government Engineering Colleges in India

Top 10 Government Engineering Colleges in India

These Government Engineering Colleges in India are really good for all kind of stuff like Education , research , Placement and New Innovation Ideas etc... But Getting seat in these colleges are heavy competition in students .....

Top 10 Colleges In India 2014

Top 10 Colleges In India 2014

Indian Institute Of Technology Delhi,Indian Institute Of Technology Bombay,Indian Institute Of Technology Kanpur,Indian Institute Of Technology Madras,Indian Institute Of Technology Kharagpur,Indian Institute Of Technology Roorkee,University Of Delhi,Indian Institute Of Technology Guwahati,University Of Calcutta,University Of Mumbai, National Institute Of Technology,Trichy.

2014 LATEST SURVEY TOP RANKING ENGINEERING COLLEGES IN INDIA

2014 LATEST SURVEY TOP RANKING ENGINEERING COLLEGES IN INDIA

This below survey was taken many form many colleges in India. These Top 100 Engineering Colleges in India have Good Infrastructure, Good Environment, Educations , Staff, Placement , Research Activities and other Facilities are good. If you want to do Engineering as your dream and try out these colleges

Subscribe Now!

Enter your email address:

Showing posts with label DOT NET. Show all posts
Showing posts with label DOT NET. Show all posts

Monday, June 20, 2016

Send Crystal Report to PDF in Email Attachment

Export Crystal Report to PDF & send in Email as Attachment in ASP.Net using C# (MVC C#)

Send Crystal Report to PDF in Email Attachment


Name Spaces 

using System.Net.Http.Headers;
using System.IO;
using System.Net.Mail;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Net;
using System.Data;
using System.Configuration;





Method To send Email


 public ActionResult PrintJobOffer()
        {                      
               myReport.FileName = Server.MapPath("~/Report/Permanant.rpt");
                            myReport.Load();
                            myReport.SetParameterValue("FULLNAME", Data.FULLNAME);
                            myReport.SetParameterValue("NATIONALITY", Data.NATIONALITY);
                            myReport.SetParameterValue("PASSPLACEOFISSUE", Data.PASSPLACEOFISSUE);
                           
                            using (MailMessage message = new MailMessage())
                            {
                                string messageto = "amdi@gmail.com"; // to Email Address
                                message.From = new MailAddress("no_reply@med.com");
                                message.To.Add(new MailAddress(messageto));
                                message.CC.Add(new MailAddress("copy@domain.com"));
                                message.Subject = "Job Offer - HR Department";
                                message.Attachments.Add(new Attachment(myReport.ExportToStream(ExportFormatType.PortableDocFormat), "Permanant.pdf")); //Code For Generate Pdf and sending automatically

                                string strtpath = System.Web.HttpContext.Current.Server.MapPath("~");
                                Path.GetFullPath(strtpath).Replace(@"/", @"//");

                                System.Net.Mail.Attachment attachment1;
                                attachment1 = new System.Net.Mail.Attachment(strtpath + "/assets/images/Confidential_Agreement_Form.pdf");
                                attachment1.Name = "Confidential_Agreement_Form.pdf";
                                message.Attachments.Add(attachment1);

                                System.Net.Mail.Attachment attachment2;
                                attachment2 = new System.Net.Mail.Attachment(strtpath + "/assets/images/Prior_of_Arraiving.pdf");
                                attachment2.Name = "Prior_of_Arraiving.pdf";
                                message.Attachments.Add(attachment2);              
                         
                                message.IsBodyHtml = true;
                                message.Body = "Dear Candidate"; // Body Content
                                SmtpClient client = new SmtpClient();
                                client.Host = "10.90.10.10"; // Server Email Ip Address 
                                client.Port = 25; // Port For Email
                                client.Send(message);
For Gmail
NetworkCredential credential = new NetworkCredential();
        credential.UserName = "sender@gmail.com";
        credential.Password = "xxxxx";
        smtp.UseDefaultCredentials = true;
        smtp.Credentials = credential;
        smtp.Port = 587;
        smtp.EnableSsl = true;
        smtp.Send(message);



                            }
                        }

Monday, May 30, 2016

To create a new Web site in IIS Server

This article describes how to set up your first Web site in Internet Information Services (IIS) by using the minimum number of steps that you require to prepare for a migration from Apache.




To create a new Web site in IIS Server

Configure a default Web site

When you install IIS, it is preconfigured to serve as a default Web site; however, you may want to change some of the settings. To change the basic settings for the Web site and to emulate the steps that are required to set up Apache for the first time by using the configuration file:
  1. Log on to the Web server computer as an administrator.
  2. Click Start, point to Settings, and then click Control Panel.
  3. Double-click Administrative Tools, and then double-click Internet Services Manager.
  4. Right-click the Web site that you want to configure in the left pane, and then click Properties.
  5. Click the Web site tab.
  6. Type a description for the Web site in the Description box.
  7. Type the Internet Protocol (IP) address to use for the Web site or leave the All (Unassigned) default setting.
  8. Modify the Transmission Control Protocol (TCP) port as appropriate.
  9. Click the Home Directory tab.
  10. To use a folder on the local computer, click A directory on this computer, and then click Browse to locate the folder that you want to use.
  11. To use a folder that has been shared from another computer on the network, click A share located on another computer, and then either type the network path or click Browse to select the shared folder.
  12. Click Read to grant read access to the folder (required).
  13. Click OK to accept the Web site properties.
Source : https://support.microsoft.com/en-us/kb/323972

Wednesday, March 30, 2016

Sending an Email With and Without Attachments Using C#

Sending an Email is important thing for every Dot net developer working in web applications project. Sometimes required to need send with attachments in email. Sending an email with attachment is easy and simple in C# to send. Follow the below steps to implement in your projects.

In this post I am discussing to send an email in two different ways
    1.   Send e-mail via SMTP (Gmail) using C#.
    2.   Send e-mail via Host Address using C#.



Note: Add these namespace in your code behind  or Controller in C#.
using System.Net;
using System.Net.Mail;

    1.   Send e-mail via SMTP (Gmail) using C#.
Function for Without Attachment
protected void sendEmail()
        {
            using (MailMessage message = new MailMessage())
            {
                message.From = new MailAddress("from_address@gmail.com");
                message.To.Add(new MailAddress("to_address@test.med.ca"));
                message.CC.Add(new MailAddress("copy@domain.com"));
                message.Subject = "Special Medication Request from " + txtPhyName.Text.ToString() + " , " + txtPosTile.Text; //Subject Here

                message.Body = "Drug Name: " + txtdrugName.Text.ToString() + "\n" + "Quantity: " + txtQtyReq.Text;  //Body Of Email Content
                SmtpClient client = new SmtpClient("smtp.gmail.com"));
client.Port = 587;
    client.Credentials = new System.Net.NetworkCredential("your mail@gmail.com", "your password");
    client.EnableSsl = true;
                client.Send(message);
            }
        }
Function for With Attachment
protected void sendEmail()
        {
            using (MailMessage message = new MailMessage())
            {
                message.From = new MailAddress("from_address@gmail.com");
                message.To.Add(new MailAddress("to_address@test.med.ca"));
                message.CC.Add(new MailAddress("copy@domain.com"));
                message.Subject = "Special Medication Request from " + txtPhyName.Text.ToString() + " , " + txtPosTile.Text; //Subject Here

//Attachment goes here
    System.Net.Mail.Attachment attach;
    attach = new System.Net.Mail.Attachment("c:/www/root/filename.png //file extension");
   attach.Name = "map.png"; // Here You can describe your filename with or without extension
    message.Attachments.Add(attach);

                message.Body = "Drug Name: " + txtdrugName.Text.ToString() + "\n" + "Quantity: " + txtQtyReq.Text;  //Body Of Email Content
                SmtpClient client = new SmtpClient("smtp.gmail.com"));
client.Port = 587;
    client.Credentials = new System.Net.NetworkCredential("your mail@gmail.com", "your password");
    client.EnableSsl = true;
                client.Send(message);
            }
        }
Function for With Multiple Attachments
protected void sendEmail()
        {
            using (MailMessage message = new MailMessage())
            {
                message.From = new MailAddress("from_address@gmail.com");
                message.To.Add(new MailAddress("to_address@test.med.ca"));
                message.CC.Add(new MailAddress("copy@domain.com"));
                message.Subject = "Special Medication Request from " + txtPhyName.Text.ToString() + " , " + txtPosTile.Text; //Subject Here

//Attachment 1
    System.Net.Mail.Attachment attach;
    attach = new System.Net.Mail.Attachment("c:/www/root/filename.png //file extension");
   attach.Name = "map.png"; // Here You can describe your filename with or without extension
    message.Attachments.Add(attach);

//Attachment 2
    System.Net.Mail.Attachment attach2;
    Attach2 = new System.Net.Mail.Attachment("c:/www/root/filename.png //file extension");
   Attach2.Name = "map.png"; // Here You can describe your filename with or without extension
    message.Attachments.Add(attach2); 
                message.Body = "Drug Name: " + txtdrugName.Text.ToString() + "\n" + "Quantity: " + txtQtyReq.Text;  //Body Of Email Content
                SmtpClient client = new SmtpClient("smtp.gmail.com"));
client.Port = 587;
    client.Credentials = new System.Net.NetworkCredential("your mail@gmail.com", "your password");
    client.EnableSsl = true;
                client.Send(message);
            }
        }

   2.   Send e-mail via Host Address using C#.

Function for Without Attachment
protected void sendEmail()
        {
            using (MailMessage message = new MailMessage())
            {
                message.From = new MailAddress("from_address@gmail.com");
                message.To.Add(new MailAddress("to_address@test.med.ca"));
                message.CC.Add(new MailAddress("copy@domain.com"));
                message.Subject = "Special Medication Request from " + txtPhyName.Text.ToString() + " , " + txtPosTile.Text; //Subject Here

                message.Body = "Drug Name: " + txtdrugName.Text.ToString() + "\n" + "Quantity: " + txtQtyReq.Text;  //Body Of Email Content

SmtpClient client = new SmtpClient();
                client.Host = "10.10.18.10"; // Mention your server host IP Address Here
    client.EnableSsl = true;
                client.Send(message);
            }
        }
Function for With Attachment
protected void sendEmail()
        {
            using (MailMessage message = new MailMessage())
            {
                message.From = new MailAddress("from_address@gmail.com");
                message.To.Add(new MailAddress("to_address@test.med.ca"));
                message.CC.Add(new MailAddress("copy@domain.com"));
                message.Subject = "Special Medication Request from " + txtPhyName.Text.ToString() + " , " + txtPosTile.Text; //Subject Here

//Attachment goes here
    System.Net.Mail.Attachment attach;
    attach = new System.Net.Mail.Attachment("c:/www/root/filename.png //file extension");
   attach.Name = "map.png"; // Here You can describe your filename with or without extension
    message.Attachments.Add(attach);

                message.Body = "Drug Name: " + txtdrugName.Text.ToString() + "\n" + "Quantity: " + txtQtyReq.Text;  //Body Of Email Content
                SmtpClient client = new SmtpClient();
                client.Host = "10.10.18.10"; // Mention your server host IP Address Here
    client.EnableSsl = true;
    client.Send(message);
            }
        }

Function for send an email Multiple Attachments Using c#
protected void sendEmail()
        {
            using (MailMessage message = new MailMessage())
            {
                message.From = new MailAddress("from_address@gmail.com");
                message.To.Add(new MailAddress("to_address@test.med.ca"));
                message.CC.Add(new MailAddress("copy@domain.com"));
                message.Subject = "Special Medication Request from " + txtPhyName.Text.ToString() + " , " + txtPosTile.Text; //Subject Here

//Attachment 1
    System.Net.Mail.Attachment attach;
    attach = new System.Net.Mail.Attachment("c:/www/root/filename.png //file extension");
   attach.Name = "map.png"; // Here You can describe your filename with or without extension
    message.Attachments.Add(attach);

//Attachment 2
    System.Net.Mail.Attachment attach2;
    Attach2 = new System.Net.Mail.Attachment("c:/www/root/filename.png //file extension");
   Attach2.Name = "map.png"; // Here You can describe your filename with or without extension
    message.Attachments.Add(attach2); 
                message.Body = "Drug Name: " + txtdrugName.Text.ToString() + "\n" + "Quantity: " + txtQtyReq.Text;  //Body Of Email Content
                SmtpClient client = new SmtpClient();
                client.Host = "10.10.18.10"; // Mention your server host IP Address Here
    client.EnableSsl = true;
                client.Send(message);
            }
        }

Using above function call in any events to send an email. We can use these in Contact us Form and many more areas where ever required.

If you have any problem in coding comment it here. As soon as possible we will reply to you.


Hope all you understood clearly and it will help you. Let enjoy coding

Sending an Email With and Without Attachments Using C#

Sending an Email With and Without Attachments Using C#

Tuesday, February 7, 2012

CONCEPTS OF OBJECT ORIENTED PROGRAMMING




CONCEPTS OF OBJECT ORIENTED PROGRAMMING:

1.Class
2.Object
3.Inheritance
4.Interface
5.Abstract Class
6.Overriding
7.Polymorphism (or ) Overloading

1.Class:

A class is simply a representation of a type of object. It is the blueprint/ plan/ template that describe the details of an object. A class is the blueprint from which the individual objects are created. Class is composed of three things: a name, attributes, and operations.
Examples 1
public class Student
{
}

2.Object:

An object can be considered a thing that can perform a set of related activities. The set of activities that the object performs defines the object’s behavior.
In pure OOP terms an object is an instance of a class.
Examples 2
Student objectStudent = new Student();
In Example 2 we can say that the student object, named objectStudent, has created out of the Student class.

3.Inheritance:

Ability of a new class to be created, from an existing class by extending it, is called inheritance.
Examples 3
public class Exception
{
}
public class IOException : Exception
{
}
In Example 3 the new class (IOException), which is called the derived class or subclass, inherits the members of an existing class (Exception), which is called the base class or super-class. The class IOException can extend the functionality of the class Exception by adding new types and methods.

4.Interface:

An interface is type definition similar to a class except that it purely represents a contract between an object and a user of the object. An interface cannot be directly instantiated as an object. No data members can be defined in an interface. Methods and properties can only be declared, not defined. To prefix the name interfaces with’I’ like IDisposable, ISerializable, ICloneable, IEnumerator, etc.
Examples 4
interface IShape
{
void Draw();
double X { get; set; }
double Y { get; set; }
}
Implementing an interface is simply done by inheriting off the interface and then defining all the methods and properties declared by the interface.
Examples 5
class Square : IShape
{
private double mX, mY;
public void Draw() { … }
public double X
{
set { mX = value; }
get { return mX; }
}
public double Y
{
set { mY = value; }
get { return mY; }
}
}

5.Abstract Class:

Abstract class can be simply defined as incomplete classes. Abstract classes contain one or more incomplete methods called abstract methods. The abstract class only provides the signature or declaration of the abstract methods and leaves the implementation of these methods to derived or sub-classes. Abstract method and abstract classes are marked with the abstract keyword. An abstract class itself must be marked with the abstract keyword. Since abstract classes are incomplete, they cannot be instantiated. The class inheriting an abstract class and implementing all its abstract methods is called the concrete of the abstract class.
Examples 6
abstract class TaxCalculator
{
protected double itemPrice;
protected double tax;
public abstract double CalculatorTax();
public double Tax
{
get { return tax };
}
public double ItemPrice
{
get { return itemPrice };
}
}

6.Overriding:

Override modifier is to modify a method, a property, an indexer, or an event. An override method provides a new implementation of a member inherited from a base class. The method overridden by an override declaration is known as the overridden base method. The overridden base method must have the same signature as the override method. You cannot override a non-virtual or static method. The overridden base method must be virtual, abstract, or override. An override declaration cannot change the accessibility of the virtual method. Both the override method and the virtual method must have the same access level modifier.
Examples 7
public class Employee
{
public virtual void GetPayCheck()
{
}
public void Work()
{
}
}
public class Executive : Employee
{
GetPayCheck method;
public override void GetPayCheck()
{
}
public void AdministerEmployee()
{
}
}

7.Polymorphism (OR) Overloading:

Polymorphism is the ability for classes to provide different implementations of methods that are called by the same name. In example 8 how polymorphism would work, here’s a different class that implements the same interface but has different code. Polymorphism allows us to define methods in a base class and override them with derived class implementations.
Examples 8
public class MyLogger
{
public void LogError(Exception e)
{
}
public bool LogError(Exception e, string message)
{
}
}

Related Posts Plugin for WordPress, Blogger...