mail for ASP.NET email smtp mail for ASP.NET email smtp
mail for ASP.NET email smtp

Other Products
mail for ASP.NET email smtp
 
    
    

Using aspNetEmail in Visual Studio .NET [Visual Basic]

Summary

The following article will describe how to use aspNetEmail from Visual Studio .NET using VB.NET.  This brief tutorial assumes you have IIS installed locally on your machine, and have downloaded and installed aspNetEmail from www.aspNetEmail.com

Instructions

Using Visual Studio .NET (VS.NET ) We will create a single webform (emailtest.aspx) and send out an email.

Creating the Project
Using the following instructions, create a c# project on local server.

1. Launch Visual Studio .NET

2. From the main menu, select the File | New | Project command.

3. The New Project dialog box appears. Under Project Types, Select Visual Basic Projects. Under Templates, select ASP.NET Web Application. In the Location textbox, enter http://localhost/aspNetEmailTest

Setting the Reference to aspNetEmail.
There are two ways to set a reference in VS.NET. Because aspNetEmail is installed in the GAC (Global Assembly Cache) you can set a reference to the GAC copy, or you can upload aspNetEmail to the project and set a reference to the uploaded copy.  We will upload a copy, and set a reference to the uploaded copy. This method will promote XCOPY deployment, considered a best practice by Microsoft. (A comment about licensing: Please be sure you are compliant with your licenses. Check http://www.aspNetEmail.com/licen.aspx for more information.)

1. In the Solution Explorer, right-click the project name, aspNetEmailTest, and select the Add | Add Existing Item command.

2. The Add Existing Item dialog box appears. Under Files of Type, select All Files(*.*).Navigate to the aspNetEmail install directory. By default, this directory is C:\Program Files\AdvancedIntellect\aspNetEmail. Double-click the aspNetEmail.dll. The Add Existing Item dialog box closes, and the aspNetEmail.dll was uploaded to the root directory of your project.

3. In the Solution Explorer, right-click the project name aspNetEmailTest and select Add Reference. The Add Reference dialog box appears. Click the Browse button. The Select Component dialog box appears. Double-click the aspNetEmail.dll file. The Select Component dialog box closes. Click OK. The Add Reference dialog box closes, and a reference is set to aspNetEmail.

Create a Test Page.
Now that we have a reference set, let's create a test page to check aspNetEmail.

1. In the Solution Explorer, right-click the project name aspNetEmail test, and select Add | Add Webform. The Add New Item dialog box appears. In the Name textbox, enter, emailtest.aspx.

2. In the Solution Explorer, right-click emailtest.aspx, and select View Code.

3. Under the Page_Load function, replace the line

 'Put user code to initialize the page here
 

With the following code.

Dim msg As New aspNetEmail.EmailMessage()
msg.Server = "Mail.mycompany.com"
msg.FromAddress = "me@mycompany.com"
msg.To = "You@yourcompany.com"
msg.Subject = "Test Email"
msg.Body = "This is a test email."
If msg.Send() Then
Response.Write("Message Sent.")
Else
Response.Write(("The following error occurred: " + msg.LastException().Message))
End If
 

You will need to replace the following properties with values that will work with your system:

msg.Server = "Mail.mycompany.com"
msg.FromAddress = "me@mycompany.com"
msg.To = "You@yourcompany.com"
 

Testing The Page
Lets compile and test the page.

1. In the Solution Explorer, right-click the project name, aspNetEmailTest, and select Build. The project will be compiled.

2. In the Solution Explorer, right-click emailtest.aspx and select View in Browser.

3. Check your email to verify the email was sent to the 'To' address found on the line of code:

msg.To = "You@yourcompany.com"
 

Summary
 

That's all there is to using aspNetEmail from Visual Studio .NET. In these few simple steps you were able to create a project, set a reference to aspNetEmail, and send a sample email.

For more questions or comments, feel free to write support@aspNetEmail.com

The box is not shipped.
aspNetEmail is a    
downloadable product.
 
aspNetEmail
Voted Number 1 ASP.NET Email Control
Voted Best Email Control


aspNetEmail
Runner Up ASP.NET Email Control
Voted Runner Up Email Control


aspNetEmail
Voted Number 1 ASP.NET Email Control
Voted Best Email Control


aspNetEmail
Voted Number 1 ASP.NET Email Control
Voted Best Email Control


aspNetEmail
Voted Number 1 ASP.NET Email Control
Voted Best Email Control


aspNetTraceRoute
Voted Runner Up Networking Control
Runner Up - Networking Control