All About ASP.NET and ASP.NET Core 2 Hosting BLOG

Tutorial and Articles about ASP.NET and the latest ASP.NET Core

ASP.NET Hosting Singapore (ASIA) - :: How to use Bootstrap is ASP.NET?

clock April 30, 2014 05:58 by author Ben

Designers need a solid foundation that gives us almost everything a typical website would require but is flexible enough for customization. Thanks to hundreds of hours spent by some developers and companies, we now have dozens of CSS Frameworks to choose from. Among all the available CSS frameworks out there, Bootstrap is my favorite and also one of the most widely used.

Bootstrap is the new technology that is integrated with the ASP.NET web project templates. It is builtin with the projects that provides responsive design and theming capabilities. Bootstrap is a sleek and powerful front-end framework for faster web development. The project templates based on bootstrap technology provides attractive themes for the web development. Bootstrap is front-end framework for easy and faster web development. This post explains how to use Bootstrap in  ASP.NET applications and outlines some of the features of this framework. Create a new ASP.NET project in Visual Studio 2013 and execute it then you will see the look and feel of the page as below.

If you want to get the above look without using Bootstrap then you have to write lot of custom CSS. Now all ASP.NET default templates like MVC, Web forms, Single Page applications and Web API are using Bootstrap framework. Bootstrap version 3 is integrated in Visual Studio 2013. The above screen scales well on different devices. If you look at the CSS code to achieve is very few lines as shown below

In order to get the Bootstrap into your project, go to Manage NuGet packages window and type Bootstrap in search box then you will find the package

Once you install the package then it brings the following files into your project, All the CSS and JavaScript files related Bootstrap framework are bundled for you to get you better performance.

Another integration feature for Bootstrap is Bootswatch, which helps you to theme your site. To apply theme to your site go to Bootswatch site and choose the theme which you like and download and copy the CSS and overwrite the  Bootstrap.css in your project. After applying one of the sample free theme then the site looks as below, In matter of seconds you can quickly change the theme of your site.

Another key feature of Bootstrap is dealing with the images, it makes the image experience as responsive without writing any code! just use the class name img-responsive.

It adds the responsive behaviour to the image and it make sure to render nicely in your site.

Reasons to trust your ASP.NET website to us

  • Server and performance - We're proud to host all of our sites in Amsterdams, USA and Singapore. We use special server technology on our web servers to offer the fastest loading time for your websites. Stable, Secure and Reliable ASP.NET hosting service.
  • 24/7-based Support - We never fall asleep and we run a service that is operating 24/7 a year. Even everyone is on holiday during Easter or Christmas/New Year, we are always behind our desk serving our customers.
  • Excellent Uptime Rate - Our key strength in delivering the service to you is to maintain our server uptime rate. We never ever happy to see your site goes down and we truly understand that it will hurt your onlines business. If your service is down, it will certainly become our pain and we will certainly look for the right pill to kill the pain ASAP.
  • High Performance and Reliable Server - We never ever overload our server with tons of clients. We always load balance our server to make sure we can deliver an excellent service, coupling with the high performance and reliable server.
  • Experts in ASP.NET Hosting - Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up
  • Daily Backup Service - We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it.

About is a hosting company that best support in Windows and ASP.NET-based hosting. Services include shared hosting, reseller hosting, and sharepoint hosting, with specialty in ASP.NET, SQL Server, and architecting highly scalable solutions. As a leading small to mid-sized business web hosting provider, strive to offer the most technologically advanced hosting solutions available to all customers across the world. Security, reliability, and performance are at the core of hosting operations to ensure each site and/or application hosted is highly secured and performs at optimum level.

ASP.NET Cloud Hosting with How to Encrypt and Decrypt Password Using ASP.NET

clock April 11, 2014 12:40 by author Ben

Encryption is the process of translating plain text data into something that appears to be random and meaningless. Decryption is the process of translating random and meaningless data to plain text. Why we need to use this Encryption and decryption processes. By using this process we can hide original data and display some junk data based on this we can provide some security for our data. Here I will explain how to encrypt data and how to save that data into database after that I will show how to decrypt that encrypted data in database and how we can display that decrypted data on form. I have a form with four fileds username, password, firstname, lastname here I am encrypting password data and saving that data into database after that I am getting from database and decrypting the encrypted password data and displaying that data using gridview.


Please write this syntax code :

After that add System.Text namespace in code behind because in this namespace contains classes representing ASCII and Unicode character encodings. After that add following code in code behind and design one table in database with four fields and give name as "SampleUserdetails".

private const string strconneciton = "Data Source=MYCBJ017550027;Initial Catalog=MySamplesDB;Integrated Security=True";
SqlConnection con = new SqlConnection(strconneciton);
protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
protected void btnSubmit_Click(object sender, EventArgs e)
string strpassword = Encryptdata(txtPassword.Text);
SqlCommand cmd = new SqlCommand("insert into SampleUserdetails(UserName,Password,FirstName,LastName) values('" + txtname.Text + "','" + strpassword + "','" + txtfname.Text + "','" + txtlname.Text + "')", con);
protected void BindencryptedData()
SqlCommand cmd = new SqlCommand("select * from SampleUserdetails", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
gvUsers.DataSource = ds;
protected void BindDecryptedData()
SqlCommand cmd = new SqlCommand("select * from SampleUserdetails", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
gvdecryption.DataSource = ds;
private string Encryptdata(string password)
string strmsg = string.Empty;
byte[] encode = new byte[password.Length];
encode = Encoding.UTF8.GetBytes(password);
strmsg = Convert.ToBase64String(encode);
return strmsg;
private string Decryptdata(string encryptpwd)
string decryptpwd = string.Empty;
UTF8Encoding encodepwd = new UTF8Encoding();
Decoder Decode = encodepwd.GetDecoder();
byte[] todecode_byte = Convert.FromBase64String(encryptpwd);
int charCount = Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
char[] decoded_char = new char[charCount];
Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
decryptpwd = new String(decoded_char);
return decryptpwd;
protected void gvdecryption_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow)
string decryptpassword = e.Row.Cells[2].Text;
e.Row.Cells[2].Text = Decryptdata(decryptpassword);

And the result 


Happy Programming !!!

Need ASP.NET cloud hosting? Please visit our site at Just with only $4.00/month to get ASP.NET cloud hosting. If you have any further questions, please feel free to email us at

Reasons why you must trust

Every provider will tell you how they treat their support, uptime, expertise, guarantees, etc., are. Take a close look. What they’re really offering you is nothing close to what ASPHostPortal does. You will be treated with respect and provided the courtesy and service you would expect from a world-class web hosting business.

You’ll have highly trained, skilled professional technical support people ready, willing, and wanting to help you 24 hours a day. Your web hosting account servers are monitored from three monitoring points, with two alert points, every minute, 24 hours a day, 7 days a week, 365 days a year.


ASP.NET 4.5.1 Windows Cloud Hosting - With :: How to Transferring User Accounts from ASP.NET to MojoPortal

clock April 10, 2014 08:24 by author Kenny

MojoPortal is a free and open source content management system that allows you to maintain your Web site with no HTML coding knowledge. When you need to build a web application you usually have some business functionality in mind but there is always a certain amount of web plumbing that needs to be implemented for things like navigation, authentication of users, security and roles and other things that are needed to support most kinds of business application logic. Sometimes we need to transfer user accounts from existing ASP.NET membership based sites into MojoPortal. So, in this article i will explain about how to transferring user accounts from ASP.NET to MojoPortal.

For the first step, you must set MojoPortal to use plain text passwords.
And then, create a folder on your PC to contain the scripts > in this folder create the following .bat files:


set login=-U [Username] -P [Password] -S [SQL Server Instance]
set database=[Databasename].[Schema].
set switches= -c -x
set formatDir=[Full path to formats directory with trailing slash]
bcp %database%mp_Users format nul %login% %switches% -f
bcp %database%mp_UserProperties format nul %login% %switches% -f
bcp %database%mp_userRoles format nul %login% %switches% -f


set login=-U [Username] -P [Password] -S [SQL Server Instance]
set dataDir=[Full path to data directory with trailing slash]
set database=[Databasename].[Schema].
set switches= -k –c
bcp "SELECT 0 AS UserID, 1 AS SiteID, aspnet_Users.Username AS Name,
aspnet_Users.UserName AS LoginName, COALESCE
(aspnet_Membership.Email,aspnet_Users.UserName + '' ) AS
Email, aspnet_Membership.LoweredEmail AS LoweredEmail, NULL AS
PasswordQuestion, NULL AS PasswordAnswer, NULL AS Gender,
aspnet_Membership.IsApproved AS ProfileApproved, NULL AS RegisterConfirmGUID,
aspnet_Membership.IsApproved AS ApprovedForForums, 0 AS Trusted, CASE
aspnet_Roles.RoleName WHEN 'xg' THEN 0 ELSE 1 END AS DisplayInMemberList, NULL
AS WebsiteURL, NULL AS Country, NULL AS [State], NULL AS Occupation, NULL AS
TotalPosts, NULL AS AvatarURL, 0 AS TimeOffsetHours, NULL AS [Signature],
aspnet_Membership.CreateDate AS DateCreated, aspnet_Membership.UserId AS
userGUID, NULL AS Skin, 0 AS IsDeleted, aspnet_Users.LastActivityDate AS
LastActivityDate, aspnet_Membership.LastLoginDate AS LastLoginDate, NULL AS
LastPasswordChangedDate, NULL AS LastLockoutDate, 0 AS
FailedPasswordAttemptCount, NULL AS FailedPwdAttemptWindowStart, 0 AS
FailedPwdAttemptCount, NULL AS FailedPwdAnswerWindowStart,
aspnet_Membership.IsLockedOut AS IsLockedOut, NULL AS MobilePin, NULL AS
PasswordSalt, NULL AS Comment, NULL AS OpenIDURI, NULL AS WindowsLiveID,
'77C33D82-D6F0-49ED-95A7-84C11919AD94' AS SiteGUID, NULL AS TotalRevenue,
userInfo.ForeName AS FirstName, userInfo.Surname AS LastName,
aspnet_Users.Username as Pwd, 1 AS MustChangePassword, NULL AS NewEmail, NULL
AS EditorPreference, '00000000-0000-0000-0000-000000000000' AS EmailChangeGuid,
NULL AS TimeZoneID, '00000000-0000-0000-0000-000000000000' AS PasswordResetGuid
FROM %database%aspnet_Membership INNER JOIN %database %aspnet_Users ON
aspnet_Membership.UserId=aspnet_Users.UserId INNER JOIN %database%userInfo on
aspnet_Membership.UserId=userInfo.userId INNER JOIN
%database%aspnet_UsersInRoles ON
aspnet_Membership.UserId=aspnet_UsersInRoles.UserId INNER JOIN
%database%aspnet_Roles ON aspnet_UsersInRoles.RoleId =
aspnet_Roles.RoleId" queryout %dataDir%lharUsers.txt %switches% %login% -o
bcp "select RoleName,UserId from %database%aspnet_Roles INNER JOIN
%database%aspnet_UsersInRoles on
aspnet_Roles.RoleId=aspnet_UsersInRoles.RoleId" queryout
%dataDir%lharUsersRoles.txt %switches% %login% -o output/userRolesOutput.txt
bcp "SELECT newid() AS PropertyID, UserId AS userGUID, [String to use
as MojoPortal PropertyName] AS PropertyName, Title AS PropertyValueString,
NULL AS PropertyValueBinary, GETDATE() AS LastUpdatedDate, 0 AS IsLazyLoaded
FROM %database%UserInfo
SELECT newid() AS PropertyID, UserId AS userGUID, [String to use as
MojoPortal PropertyName] AS PropertyName, Title AS PropertyValueString,
NULL AS PropertyValueBinary, GETDATE() AS LastUpdatedDate, 0 AS IsLazyLoaded
FROM %database%UserInfo" queryout %dataDir%lharUserProfiles.txt %switches%
%login% -o output/userPropertiesOutput.txt


set login=-U [Username] -P [Password] -S [SQL Server Instance]
set database=[Databasename].[Schema].
set dataDir=[Full path to data directory with trailing slash]

set switches= -k -R

set formatDir=[Full path to outputs directory with trailing slash]

bcp %database%mp_users IN %dataDir%lharUsers.txt %login% %switches% -f %formatDir%mojoUsers.xml -o output/importUsers.txt

bcp %database%mp_userProperties IN %dataDir%lharUserProfiles.txt %login% %switches% -f %formatDir%mojoUserProperties.xml -o output/importUserProperties.txt

bcp %database%mp_userRoles IN %dataDir%lharUsersRoles.txt %login% %switches% -f %formatDir%mp_userRoles.xml -o output/importUserRoles.txt

Next step is, create the following subdirectories in this folder: data, formats, output.
After create the CreateMojoUserTablesXMLFormats.bat file and the ExportASPNETUserData.bat file, run these program.
Don’t forget to check the output directory for any errors and check the data files have been created and contain the data you expect.
After that, run the ImportMojoPortalUserData.bat. Check the output directory for any errors and check the database tables have the data.
Switch MojoPortal back to using encrypted passwords and the last test a few logins.

ASP.NET Hosting Full Trust Mode

clock April 8, 2014 09:03 by author Diego

What’s ASP.NET shared hosting trust level?

You need to check many aspects before choosing a .Net hosting provider, those aspects should include .Net MVC framework, SQL Server, disk space, monthly bandwidth, hosting prices, but there’s one thing you may ignore really – “IIS Security Trust Level”.

If you’re not familiar with what’s shared hosting trust level, here I’d like to bring you a short introduction. The trust level is real important that could affect with your site secure and performance, and a full trust level means higher risk for hackers sneak into server to make destroy. Most of small .Net hosts only can give medium trust level on their servers. If your applications need to be run a full trust mode, then you’ve to look for a web host which can give full permission to you.

<trustLevel name="High" policyFile="web_hightrust.config"/>
<trustLevel name="Medium" policyFile="web_mediumtrust.config"/>
<trustLevel name="Low" policyFile="web_lowtrust.config"/>
<trustLevel name="Minimal" policyFile="web_minimaltrust.config"/>

You can see there are 4 trust levels for web hosts to pre-set by default – Minimal trust, Low trust, Medium trust and High / Full trust. High trust means higher risk for hackers to sneak into server, most of Windows hosting companies doesn’t allow their customers to run full trust level by default.
- Full Trust allows the users to do everything of application pool on one Windows web server. Some of applications cannot work properly under a medium trust web server, full trust means more flexible and you’re also able to change to medium trust once your application don’t need full trust.
- High Trust, websites are limited to call unmanaged code, e.g. Win32 APIs, COM interop.
- Medium Trust level websites are limited to access the file system and not so flexible as full trust level web server.
- Low Trust & Minimal Trust level are 2 options to restrict the users heavily, it won’t allow users to connect to server actively. At present, there’s no Windows hosts offering such shared hosting plan yet.

With more and more people and companies developing websites by Microsoft .NET technology, ASP.NET shared web hosting comes to be the major solution provided by many web hosting companies. Most of people choose an ASP.NET web host considering about .NET framework version, ASP.NET MVC support, SQL Server database, disk space or bandwidth but they usually ignore the most important feature “IIS security level”. That determines whether the ASP.NET websites can run successfully on the shared web host. In result to, if you developing an ASP.NET website that works well in the local development environment and attempt to run it in the ASP.NET shared web host, you may get the following exception.

System.Security.SecurityException: That assembly does not allow partially trusted callers.

This is caused by the security level of the ASP.NET shared web host that your application is forced to run with the limited permission, by locking down the access to server file system, preventing the background threads, or interacting with COM interfaces, etc.
Full Trust and Medium Trust are two widely used levels in ASP.NET shared web hosting. The full trust provides best flexibility but it has potential security issues to the shared server, especially when the web hosting provider doesn't have rich experience on setting up Windows permission and IIS. Compared to Full Trust, you have to review the website carefully before you go with a web host only supports Medium Trust Level. You can refer to the following checkpoints for the review.
-The website shall not call unmanaged APIs.

-The website shall not access to file system, system registry, event logs and anything else related to the system.
-The website shall not generate code for execution dynamically using Code DOM.

-The website shall not use XslTransform to transform something from XML using XSLT.

-The website has to be signed with a Strong Name.

Check with the web page from Microsoft about which namespaces and classes are not supported in Medium Trust environment.
And here is quick way to confirm the compatibility of websites to Medium Trust Level, in the local environment.

1. Add partially trusted callers attribute into AssemblyInfo.cs file of the website project, as following code snippet,
[assembly: AllowPartiallyTrustedCallers]

2.Add the following line into the web.config,
<trust level="Medium" />

Medium Trust or Full Trust level? UP to Your choice:
If your website can be working fine under medium trust level, I suggest you don’t need a full trust hosting, most of popular .Net applications should be working fine under a medium trust level server, only when your application has to be run under a full trust level enviroment, then you can find an ASP.NET full trust hosting company. Proudly Announces SQL Server 2014 Hosting

clock April 8, 2014 08:00 by author Ben, a reliable web hosting company specializing in ASP.NET hosting services, announces the deployment of SQL Server 2014 in its web hosting packages. now provides the SQL Server 2014 in all of web hosting packages, assisting all their web hosting customers on organizing, improving and securing business’ data. Making business decisions are the crucial steps that businesses need to take, mostly in short time. It requires accessing company’s data in easy manner to be analyzed and evaluated. The SQL Server 2014 has the excellent tool to do this. With the Power View, businesses will be able to excerpt data into PowerPoint presentations and bring updated information in every meeting.


Businesses are often must face complicated issues, whether it occurs inside the organization or related to clients and customers. For example, clients often want their data quality being improved regularly that can be a challenging task. With the SQL Server 2014 this process can be reduced this problem since it has the ability to enhance the consistency and accuracy of the data. The SQL Server 2014 works by cleaning out the data thus resulting in superior quality and enduring maintenance.

The basic shared hosting service is supported by SQL Server 2014 web hosting and the site provides this plan at a monthly cost of $5. The site assures a 24x7 customer support service and guarantees a 99.9% uptime as they have installed fully servers. The company through its website gives all its customers a Plesk Panel which is basically server management software.

“Our customers have been asking us about SQL Server 2014 and we are happy to deliver a hosting platform that supports all the latest in the Microsoft Web Stack.” said said Dean Thomas, Manager at  "And it proves that we remain at the forefront in Microsoft technology". is a popular SQL Server 2014 hosting service provider with all of its  hosting plans to help users to automate and simplify website and server administration tasks such as  installation and migration. For more information about this topics or have any enquiries related to SQL Server 2014 hosting,  please visit is now providing this FREE DOMAIN and DOUBLE SQL Space promotion link for new clients to enjoy the company's outstanding web hosting service at a low cost from just $5.00/mo. This offer valids only from 21st March 2014 to 20 April 2014 and it applies to all the new clients registered during these dates only.

About is a hosting company that best support in Windows and ASP.NET-based hosting. Services include shared hosting, reseller hosting, and sharepoint hosting, with specialty in ASP.NET, SQL Server, and architecting highly scalable solutions. As a leading small to mid-sized business web hosting provider, strive to offer the most technologically advanced hosting solutions available to all customers across the world. Security, reliability, and performance are at the core of hosting operations to ensure each site and/or application hosted is highly secured and performs at optimum level.

Free Trial ASP.NET 4.5 Hosting with :: How to Resolve Unobtrusive validation on Your ASP.NET 4.5 Apps

clock April 4, 2014 08:36 by author Ben

Now, I want to tell you How to Resolve Unobtrusive validation on Your ASP.NET 4.5 Apps.

By default, ASP.NET 4.5 has changed the way validation works. On the surface, it works exactly the same as usual, but under the hood, now it uses by default a new kind of unobtrusive validation based in jQuery, instead of the previous default scripts.

Now, the client-side validation is made in a simpler way by using the jQuery validation plugin, and by decorating the different controls with “data-val” attributes, instead of polluting your page with a lot of validation scripts.

For example, this is the resulting HTML for a Requiredvalidator control when you are using the unobtrusive validation mode:





Notice all those “data-val” attributes. By simply inspecting this code you can easily tell how this validation control is behaving. That’s great!

However, if you create a new Empty Web Application using Visual Studio 2012 or later and add a validation control to one page, when you run the app you’ll get this error screen:


“UnobtrusiveValidationMode requires a ScriptResourceMapping for jQuery”
You get this error because the validation scripts search for a script resource called “jquery”, and it’s not present in your app.

You have several options to make it work correctly:

1. Disable the unobtrusive validation on a per-page fashion.
This enables again the former validation system from previous ASP.NET Web Forms versions (up to v.4.0).
Doing this bay hand is tedious if you have more than one or two pages, but is easy. You just need to add this line to the Load event of your page:
Page.UnobtrusiveValidationMode = System.Web.UI.UnobtrusiveValidationMode.None;

2. Disable de unobtrusive validation for the whole app.
For achieving this you just need to add one line to our web.config file, under the app.settings node, like this:

<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />


3. Add a ScriptResourceMapping for jQuery, as indicated in the error page.
For achieving this, first you need to download the latest version of jQuery. Download both available editions (the production and development one) and copy those .js files to a “scripts” folder in your app’s root folder.

Now we need to add the Global.asax file to your project. In the Application_Start event you need to define a new ScriptResourceMapping with the name “jquery”, so that the framework knows where to get the jQuery scripts.
This is the needed code in C#:

protected void Application_Start(object sender, EventArgs e)



                new ScriptResourceDefinition


                    Path = "~/scripts/jquery-1.8.3.min.js",

                    DebugPath = "~/scripts/jquery-1.8.3.js",

                    CdnPath = "http://<a title="ajax" href="#">ajax</a><a title="ajax" href="#">ajax</a>/jQuery/jquery-1.8.3.min.js",

                    CdnDebugPath = "http://<a title="ajax" href="#">ajax</a>#"



Don’t forget to include a:

using System.Web.UI;

at the beginning of the page.


Free Trial ASP.NET 4.5.1 Hosting with :: How to Send Bulk Email Using ASP.Net 4.5

clock April 3, 2014 12:14 by author Kenny

In this article I’m going to explain about how to send bulk email using ASP.Net 4.5. Bulk email software is software that is used to send email in large quantities. Bulk mail broadly refers to mail that is mailed and processed in bulk at reduced rates. The term does not denote any particular purpose for the mail; but in general usage is synonymous with "junk mail". This tutorial we will use ASP.NET Web Page for provide the user interface for your Web applications, Grid View for enables you to select, sort, and edit values of a data source in a table where each column represents a field and each row represents a record, HTML Email Templates and Gmail SMTP Mail Server.

Let’s start to try this tutorial, for the first step you must create a new project.
Click "File" -> "New" -> choose "Project..." and then select web "ASP .Net Web Forms Application". Name it as "Bulk Email".
And now let’s see in the Design page “Default.aspx” design the web page as in the following screen:

This is code for Design Source (Default.aspx):

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="BulkEmail._Default" %>
<asp:Content runat="server" ID="FeaturedContent" ContentPlaceHolderID="FeaturedContent">
    <section class="featured">
        <div class="content-wrapper">
            <hgroup class="title">              
                <h2>Send Bulk email using</h2>
            <p>To learn more about ASP.NET
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
       <h3>We suggest the following:</h3>
    <asp:Panel ID="Panel1" runat="server" Width="100%" ScrollBars="Horizontal">
       <asp:Button ID="btnBind" runat="server" Text="View" OnClick="btnBind_Click" /> <asp:Label
ID="Label1" runat="server" Font-Bold="true" ForeColor="Green" Text="Total
</asp:Label><asp:Label ID="lbltotalcount" runat="server" ForeColor="Red" Font
Size="Larger"></asp:Label> </p>
        <asp:Button ID="btnSend" runat="server" Text="Send" OnClick="btnSend_Click" />
        <asp:GridView ID="grvCustomers" runat="server"></asp:GridView>

In the Web.config file create the connection string as:

<add name="ConnectionString"connectionString="Server=localhost;userid=root;password=;Database=

In the code behind file (Default.aspx.cs) write the code as:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

//Using namespaces 
using MySql.Data.MySqlClient;
using System.Configuration;
using System.Text;
using System.Net;
using System.Net.Mail;
using System.Data;

namespace BulkEmail
    public partial class _Default : Page
        #region MySqlConnection Connection
        MySqlConnection conn = new

        protected void Page_Load(object sender, EventArgs e)
                if (!Page.IsPostBack)

            catch (Exception ex)
        #region show message
        /// <summary>
        /// This function is used for show message.
        /// </summary>
        /// <param name="msg"></param>
        void ShowMessage(string msg)
            ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script
language='javascript'>alert('" + msg + "');</script>");
        #region Bind Data
        /// <summary>
        /// This display the data fetched from the table using MySQLCommand,DataSet and
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnBind_Click(object sender, EventArgs e)
                MySqlCommand cmd = new MySqlCommand("Select
CustomerID,ContactName,Address,Phone,Email from customers", conn);
                MySqlDataAdapter adp = new MySqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                grvCustomers.DataSource = ds;
                lbltotalcount.Text = grvCustomers.Rows.Count.ToString();
            catch (MySqlException ex)

            btnBind.Visible = false;
        #region Bulk email,GridView,gmail
        /// <summary>
        /// this code used to Send Bulk email 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSend_Click(object sender, EventArgs e)
                lbltotalcount.Text = string.Empty;
                foreach (GridViewRow grow in grvCustomers.Rows)
                    string strCustomerID = grow.Cells[0].Text.Trim();
                    string strContactName = grow.Cells[1].Text.Trim();
                    string strAddress = grow.Cells[2].Text.Trim();
                    string strPhone = grow.Cells[3].Text.Trim();
                    string strEmail = grow.Cells[4].Text.Trim();               

                    string filename = Server.MapPath("~/Event.html");
                    string mailbody = System.IO.File.ReadAllText(filename);
                    mailbody = mailbody.Replace("##NAME##", strContactName);
                    string to = strEmail;
                    string from = "";
                    MailMessage message = new MailMessage(from, to);
                    message.Subject = "Auto Response Email";
                    message.Body = mailbody;
                    message.BodyEncoding = Encoding.UTF8;
                    message.IsBodyHtml = true;
                    SmtpClient client = new SmtpClient("", 587);
                    System.Net.NetworkCredential basicCredential = newSystem.Net.NetworkCredential("", "Password");
                    client.EnableSsl = true;
                    client.UseDefaultCredentials = true;
                    client.Credentials = basicCredential;
                        ShowMessage("Email Sending successfully...!" + strContactName + " &nbsp;");                                           
                    catch (Exception ex)
            catch (MySqlException ex)

Finally, Bulk Sending an E-Mail Using ASP.NET 4.5 with HTML Email Templates and Gmail SMTP Mail Server.

Cheap ASP.NET 4.5 Hosting

We’re a company that works differently to most. Value is what we output and help our customers achieve, not how much money we put in the bank. It’s not because we are altruistic. It’s based on an even simpler principle. "Do good things, and good things will come to you".

Success for us is something that is continually experienced, not something that is reached. For us it is all about the experience – more than the journey. Life is a continual experience. We see the Internet as being an incredible amplifier to the experience of life for all of us. It can help humanity come together to explode in knowledge exploration and discussion. It is continual enlightenment of new ideas, experiences, and passions

Author Link

 photo ahp banner aspnet-01_zps87l92lcl.png


Corporate Address (Location)

170 W 56th Street, Suite 121
New York, NY 10019
United States

Tag cloud

Sign in