How to send Bulk emails with ASP.NET code

Sending emails to numerous recipients at one time is an important task for most websites. For a ASP.NET (4.0) developer, you use this function quite frequently. After following the steps in this article, you will be able to send emails to a list of people just with the click of a button.

Suppose you are maintaining an online website which has a lot of customers who visit this website and make purchases. You are maintaining a database of customers who have registered with the website and now you need to send newsletter to all the customers who have selected the option of receiving newsletters. In your coding, first of all, you need a function to retrieve records of customers from the database and then send the email addresses of selected individuals to another function which is used to forward email.

 

asp-net-code

The following sample code below retrieves a list of customers who have opted to receive newsletter. Email address of each customer is being sent to a function SendEmail through a loop. SendEmail function sends the selected message to the recipient whose email address is received as a parameter.

 

strsql = “select email from buyers where newsletter=’true'”

 

Dim cmd As New SqlCommand(strsql, conn)

Dim da As New SqlDataAdapter(cmd)

Dim dt As New DataTable

da.Fill(dt)

Dim i As Integer

For i = 0 To dt.Rows.Count – 1

If Not IsDBNull(dt.Rows.Item(0)) Then

SendEmail(dt.Rows(i).Item(0))

End If

 

Next

 

This code below extracts the email addresses of buyers who want to receive newsletters. Now, we need to write a function to send emails to the selected customers.

Following function receives an email address as a parameter, sets sender email parameters and sets the smtp credentials by creating client object, sets message object and then sends email encapsulated in message object with the parameters defined in client object.

Public Shared Function SendEmail(ByVal EmailTo As String) As String

Dim MyEmailAddress As String

Dim MyEmailPassword As String

Dim MyEmailSubject As String

Dim MyEmailBody As String

‘ Sender Email Credentials

 

MyEmailAddress = “xyz@gmail.com”

MyEmailPassword = “mypassword”

 

‘ Email Subject and Email Body

MyEmailSubject= “This is my Email Subject”

MyEmailBody = “This is the body of my Email. Here I will write about my products in detail…………….”

 

‘ SMTP Client Credentials

Dim clientObject As New SmtpClient

Dim messageObject As New MailMessage(MyEmailAddress, EmailTo)

With clientObject

.Host = “smtp.gmail.com”

.Port = 25

.EnableSsl = True

.Credentials = New System.Net.NetworkCredential(MyEmailAddress, MyEmailPassword)

 

End With

 

‘ Email Forwarding

With messageObject

.Subject = MyEmailSubject

.Body = MyEmailBody

 

End With

clientObject.Send(messageObject)

Return “Message Sent”

 

End Function

 

Namespace system.net.mail is used for sending emails through this method. We need to have access to smtp server in order to forward emails. You can get information about your smtp server from the company that hosts your website. Normally it is something like smtp.yourdomain.com or mail.yourdomain.com. SMTP credentials for gmail have been used in this example. You can get information about your specific email server from the related support pages.

5 Things Mobile Apps for Business Need to be Successful

With more than 50 percent of the population owning a smartphone, more and more businesses are starting to develop mobile business apps to cater to their clients and to generate leads. When you develop a mobile app, you can build your mobile presence and increase your sales revenues all at once. But not all small business mobile apps are designed to succeed and most end up as nothing more than an expensive novelty. If you do not take time to develop a fully functional app that offers value and is easy to use, all of your efforts will go wasted. Here are the 5 most important things we’ve learned (as a digital marketing firm) through creating mobile apps for small businesses.

A Professional Developer

The first thing your mobile app needs is a professional developer. You should never try to cut corners and costs by hiring someone under the table with very little experienced in business mobile application development. Developers know the ins and outs of mobile operating systems, platforms, and the latest web technologies. With a team working on your project, you will have peace of mind that the app will be easy to navigate and fully functional. If you do cut corners, you will be wasting your time and you can affect your reputation.

An Adequate Budget

You cannot start the development process without an adequate development budget. If you are the app designer, you still need to go through the developer to bring all of the designs that you conjured up in your head to life. You might be amazed at just how complicated it can be for a developer to breath life into what seems like a simple design. You have consider all of the elements of your design and how much it will cost to incorporate these elements. If your budget is not enough to cover the development costs, you might not be able to make your app as functional as you wanted it to be.

Original Information That Will Keep Your Customers Coming Back

Perhaps the most successful and most used application downloaded on smartphones, tablets, and iPods is Facebook. One of the main reasons why this app is so tremendously popular is because the large size of of the social media site’s audience. But when you own a business, you are not going to have millions of customers lining up to download your free app.

This is why you need to make sure that you have plenty of original content and information that you can share with your audience so that they will find your app valuable and recommend it to others. Consider your target audience, what they are looking for, and the tone you should commit to when you are creating app content.

Intro Animations to Grab Your User’s Attention

You will need to find ways to grab your user’s attention the first time they load your business application. Into animations are a great way to do this but you need to make sure you do not go overboard with the animation you choose. As your application loads, a still image will appear. You can then design the application so that the still image transitions into a short but catchy animation. Keep in mind that longer animations can affect load times. This is why you need to test which animations are best and how these animations will affect loads times before making the application live.

Loading Indicators Keep Your Users in the Loop

There is nothing more frustrating than trying to navigate through an application just to be directed to a blank screen. One of the first thing your users will think if you do not have load indicators is that the application is frozen or malfunctioning. Loading indicators and animations let your users know that the app is fully functional and waiting on your phone’s network to respond. A process indicator might be even more useful because it tells the user how much of the process has been completed.

The best mobile apps are carefully designed. You need to take time to think about what you want your users to accomplish when you are using the app and how you can help them accomplish this. Do not cut corners, make sure that you test your apps thoroughly, and you can improve your reputation instead of hindering it.

This article was written by Kyle Sanders, a seo consultant and Sales Director for MobileAppStop.com–a boutique mobile development firm that provides effective and affordable mobile app solutions for small businesses.