Tejas V Bhalani Blog

Smile! You’re at the best WordPress.com site ever

Archive for the category “Asp.Net”

Sending Email using C# and ASP.Net

Introduction
This tip describes how to send email using ASP.NET with C# and using a GMail or Yahoo! port.

Background
This code uses the System.Net.Mail namespace.

Using the code
//Sending Mail Using Gmail

//send mail using gmail id
string ToAddress = TextBox3.Text;
const string FromAddress = “your gmail id”;//For Example tejasbhalani@gmail.com
string Subject = TextBox6.Text;
String Body = TextBox4.Text;
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
mail.To.Add(ToAddress);
mail.From = new MailAddress(FromAddress);
mail.Subject = Subject;
mail.Body = Body;
mail.Priority = System.Net.Mail.MailPriority.High;
SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential(FromAddress, “gmail id password”);
client.Port = 587; // Gmail works on this port
client.Host = “smtp.gmail.com”;
client.EnableSsl = true; //Gmail works on Server Secured Layer
try
{
client.Send(mail);
}
catch (Exception error)
{
throw error;
}

//Sending Mail Using Yahoo

//send mail using yahoo id
string ToAddress = txtto.Text;const string FromAddress = “your Yahoo id”;//For Example tejasvbhalani@yahoo.com
string Subject = txtsub.Text;
String Body = txtbody.Text;
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
mail.To.Add(ToAddress);
mail.From = new MailAddress(FromAddress);
mail.Subject = Subject;
mail.Body = Body;client.Credentials = new System.Net.NetworkCredential(FromAddress, “yahoo id password”);
mail.Priority = System.Net.Mail.MailPriority.High;
SmtpClient client = new SmtpClient();
client.Port = 587;
client.Host = “smtp.mail.yahoo.com”;
client.Send(mail);

Use Code For Send Mail to any emailid………..

Open PDF file in new browser tab using ASP.NET with C#

Introduction
This tip describes how to open a PDF file in a new browser tab using ASP.NET with C#.

Using the code
We create a folder in our project and store the PDF in this folder.

function openPDF() {
var strMessage = ”;
var a = ‘http://localhost:2878/your project name/’+strMessage;
window.open(a, ‘PDF’);
return true;
}

/Java Script for that//

// Create one public variable p.
public string p;
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
p = e.CommandArgument.ToString();
this.Page.ClientScript.RegisterStartupScript(this.GetType(),
“page_index_script”,”openPDF();”,true);
}
//p variable is provide path..
//For Example:-“E-book/tejasvbhalani.pdf”
//E-book is our folder name and tejasvbhalani is our pdf file name..

Online Payments Using Paypal with Asp.Net with C#

Introduction
this code for Online Payments Using Paypal with Asp.Net …

Description
I am going to explain Step by Step Procedure, about integrating PayPal account with asp.

Step-1 Create a First Paypal Merchant Account.
–this Account Create for Salling purpose.

Step-2 Create a Second Paypal Buyer Account.
–this Account Create for purchasing purpose.

Using the code
I am going to explain Step by Step Procedure, about integrating PayPal account with asp.net Code.
you want to do online transaction using paypal.
Use this Example in your project..
This Code is Declare on your Button Click Event.

const string Server_URL = “https://www.sandbox.paypal.com/cgi-bin/webscr?”;
const string return_URL = “https://www.paypal.com/xclick/Sample@gmail.com”;
const string cancelreturn_URL = “http://www.PageWhenCancel.com/cc.fail.aspx”;
//Assigning Cmd Path as Statically to Parameter
string cmd = “_xclick”;
//Assigning business Id as Statically to Parameter
string business = “tejasn_1338137871_biz@gmail.com”;// Enter your business account here
//Assigning item name as Statically to Parameter
string item_name = “balagi waffers”;
//Passing Amount as Statically to parameter
int amount = 1000;
//Passing Currency as Statically to parameter
string currency_code = “USD”;
string redirect = “”;
//Pass your Server_Url,cmd,business,item_name,amount,currency_code variable
redirect += Server_URL;
redirect += “cmd=” + cmd;
redirect += “&business=” + business;
redirect += “&item_name=” + item_name;
redirect += “&amount=” + amount;
redirect += “&currency_code=” + currency_code;
redirect += “&return=” + return_URL;
redirect += “&cancel_return” + cancelreturn_URL;
//Redirect to the payment page
Response.Redirect(redirect);

After Click on Send Button just follow this
step –when you purchase any one value using your seller id..

–Enter your id and password run time on paypal payment time..

Example of :- tejasbhalani_per@gmail.com This Code Sucessfully Run

Online Payments Using Paypal with Asp.Net with C#

Introduction

this code for Online Payments Using Paypal with Asp.Net
Description

I am going to explain Step by Step Procedure, about integrating PayPal account with asp.

Step-1  Create a First Paypal Merchant Account.
            –this Account Create for Salling purpose.

Step-2  Create a Second Paypal Buyer Account.
             –this Account Create for purchasing purpose.

Using the code
I am going to explain Step by Step Procedure, about integrating PayPal account with asp.net Code.

you want to do online transaction using paypal. Use this Example in your project..

This Code is Declare on your Button Click Event.

const string Server_URL = https://www.sandbox.paypal.com/cgi-bin/webscr?”;
const string return_URL = https://www.paypal.com/xclick/Sample@gmail.com”;
const string cancelreturn_URL = http://www.PageWhenCancel.com/cc.fail.aspx”;

//Assigning Cmd Path as Statically to Parameter
string cmd = “_xclick”;

//Assigning business Id as Statically to Parameter
string business = “tejasn_1338137871_biz@gmail.com”;// Enter your business account here

//Assigning item name as Statically to Parameter
string item_name = “balagi waffers”;

//Passing Amount as Statically to parameter
int amount = 1000;

//Passing Currency as Statically to parameter
string currency_code = “USD”;

string redirect = “”;

//Pass your Server_Url,cmd,business,item_name,amount,currency_code variable
redirect += Server_URL;
redirect += “cmd=” + cmd;
redirect += “&business=” + business;
redirect += “&item_name=” + item_name;
redirect += “&amount=” + amount;
redirect += “&currency_code=” + currency_code;
redirect += “&return=” + return_URL;
redirect += “&cancel_return” + cancelreturn_URL;
//Redirect to the payment page
Response.Redirect(redirect);



After Click on Send Button just follow this step
–when you purchase any one value using your seller id..
–Enter your id and password run time on paypal payment time..
Example of :- tejasbhalani_per@gmail.com 
This Code Sucessfully Run

Open PDF file in new browser tab using ASP.NET with C#

Introduction
This tip describes how to open a PDF file in a new browser tab using ASP.NET with C#.

Using the code
We create a folder in our project and store the PDF in this folder.
  //Java Script for that
<script type=”text/javascript”>
    function openPDF() {
        var strMessage = <%= p%>;
        var a = http://localhost:2878/your project name/’ + strMessage;
        window.open(a, ‘PDF’);
        return true;
    }
</script>

// Create one public variable p.
public string p;
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
p = e.CommandArgument.ToString();
this.Page.ClientScript.RegisterStartupScript(this.GetType(),
“page_index_script”,“openPDF();”,true);
}
//p variable is provide path..
//For Example:-“E-book/tejasvbhalani.pdf”
//E-book is our folder name and tejasvbhalani is our pdf file name..

Sending Email using C# and ASP.Net

Introduction

This tip describes how to send email using ASP.NET with C# and using a GMail or Yahoo! port.

Background

This code uses the System.Net.Mail namespace.

Using the code
//Sending Mail Using Gmail

const string FromAddress = “your gmail id”;//For Example tejasbhalani@gmail.com
string Subject = TextBox6.Text;
String Body = TextBox4.Text;
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
mail.To.Add(ToAddress);
mail.From = new MailAddress(FromAddress)
mail.Subject = Subject;
mail.Body = Body;
mail.Priority = System.Net.Mail.MailPriority.High;
SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential(FromAddress, “gmail id password”);
client.Port = 587; // Gmail works on this port
client.Host = “smtp.gmail.com”;
client.EnableSsl = true; //Gmail works on Server Secured Layer
try
{

client.Send(mail);

}
catch (Exception error)
{

throw error;

}

//Sending Mail Using Yahoo

//send mail using yahoo idstring ToAddress = txtto.Text;
const string FromAddress = “your Yahoo id”;//For Example tejasvbhalani@yahoo.com
string Subject = txtsub.Text;
String Body = txtbody.Text;
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
mail.To.Add(ToAddress);
mail.From = new MailAddress(FromAddress);
mail.Subject = Subject;
mail.Body = Body; client.Credentials = new System.Net.NetworkCredential(FromAddress, “yahoo id password”);
mail.Priority = System.Net.Mail.MailPriority.High;
SmtpClient client = new SmtpClient();
client.Port = 587;
client.Host = “smtp.mail.yahoo.com”;
client.Send(mail);

Use Code For Send Mail to any emailid………..

Post Navigation