Using aspNetEmail from a Non-Visual Studio .NET environment.

Summary

The following steps will demonstrate how to use aspNetEmail in a non-Visual Studio .NET environment. For this ASP.NET application to work successfully you will need FTP access or file share access to your website.

Uploading aspNetEmail to your ASP.NET application

1. FTP (or through file sharing) connect to your web application.

2. Locate the /Bin directory. If there isn’t a directory named Bin you will need to create it under the root directory.

3. Upload the aspNetEmail.dll to the /Bin directory. By default, the aspNetEmail.dll can be found in c:\Program Files\advancedintellect\aspNetEmail. 

Creating a Sample Page

Once the aspNetEmail has been uploaded, you will be able to create a test ASP.NET page. The following steps will demonstrate this, using both C# and VB.NET.

1. To create a sample page, called EmailSample.aspx, start Notepad.

2. If you are using C# as your development language, enter the following code. If you are using VB.NET, that code can be found in the next step.

 

[C#]

	
<%@ Page Language="C#" %>
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
    aspNetEmail.EmailMessage msg = 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() )
    {
    Response.Write( "Message Sent.");
    }
    else
    {
    Response.Write ("The following error occurred: " + msg.LastException().Message);
    }
}
</script>
<html>
<head>
</head>
<body>
    <form runat="server" ID="Form1">
    </form>
</body>
</html>

 

[VB.NET]

	
<%@ Page Language="VB" %>
<script runat="server">
	Private  Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
    	Dim msg As aspNetEmail.EmailMessage =  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
	End Sub
</script>
<html>
<head>
</head>
<body>
    <form runat="server" ID="Form1">
        <!-- Insert content here -->
    </form>
</body>
</html>









 

4. Save this file as EmailSample.aspx and upload it to your web application.
     Note: You will need to change the Server, FromAddress, and To properties to reflect your local mail server and email addresses.

5. Open Internet Explorer (or a suitable web browser) and navigate it to your website and view the EmailSample.aspx (for example http://localhost/EmailSample.aspx).

6. The words Message Sent will appear in the browser and the email will have been sent.

Summary

That's all there is to using aspNetEmail from a Non - Visual Studio .NET environment. In these few simple steps you were able to create an email and send it from an ASP.NET page.