Click here to Skip to main content
15,888,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello every one,
i want to implement email module in my asp.net web site.
in that i want inbox,create email,send email,out box ,draft facility.
how to do that till now i have done code for sending mail but not implemented full e mailer pl help to do that.
Posted
Comments
Sunasara Imdadhusen 6-Jun-14 2:12am    
Where is your code?

1 solution

Implement the Module

1. Create a new Visual Studio .NET C# Class Library project named MyModule.
2. Set a reference to the System.Web.dll assembly.
3. Add the following directive to the class:
C#
using System.Web;

4. Rename the class SyncModule.cs, and then change the class definition to reflect this.
5. Implement the IHttpModule interface. Your class definition should appear as follows:
C#
>public class SyncModule : IHttpModule

6. Implement the Init and Dispose methods of the IHttpModule interface as follows:
C#
public void Init(HttpApplication app)
{
   app.BeginRequest += new EventHandler(OnBeginRequest);
}

public void Dispose(){ }


7.Create a delegate for an event as follows:
public delegate void MyEventHandler(Object s, EventArgs e)

8. Define a private local variable of the type MyEventHandler to hold a reference to the event:
private MyEventHandler _eventHandler = null;

9. Create an event that hooks up the delegate to the method in the Global.asax file or class that inherits from the HttpApplication object:
C#
public event MyEventHandler MyEvent
{
   add { _eventHandler += value; }
   remove { _eventHandler -= value; }
}

10. Create the OnBeginRequest method, which hooks up to the BeginRequest event of HttpApplication:
C#
public void OnBeginRequest(Object s, EventArgs e)
{
   HttpApplication app = s as HttpApplication;
   app.Context.Response.Write("Hello from OnBeginRequest in custom module.<br>");
   if(_eventHandler!=null)
      _eventHandler(this, null);
}

11. Compile the project.

Deploy the Module

1. Create a new directory under C:\Inetpub\Wwwroot named Module.
2. Create a subdirectory named Bin in the newly created Module directory. The resultant path is C:\Inetpub\Wwwroot\Module\Bin.
3. Copy MyModule.dll from your project's Bin\Debug directory to the C:\Inetpub\Wwwroot\Module\Bin directory.
4. Follow these steps to mark the new Module directory as a Web application:
a. Open Internet Services Manager.
b. Right-click the Module directory, and then click Properties.
c. On the Directory tab, click Create.
d. Click OK to close the Module Properties dialog box.

Configure the System

1. In the C:\Inetpub\Wwwroot\Module\ directory, create a new file named Web.config.
2. Paste the following text in Web.config:
XML
<configuration>
   <system.web>
      <httpModules>
         <add name="MyModule" type="MyModule.SyncModule, MyModule" />
      </httpModules>
   </system.web>
</configuration>


Test the Module;

1. In the C:\Inetpub\Wwwroot\Module directory, create a new .aspx file named Test.aspx.
2. Paste the following text into Test.aspx:
XML
<%@ Import Namespace="MyModule" %>

<script language="C#" runat=server >
protected void MyModule_OnMyEvent(Object src, EventArgs e)
{
  Context.Response.Write("Hello from MyModule_OnMyEvent called in Global.asax.<br>");
}
</script>

5. Request the Test.aspx page. You should see the following lines of text:
Quote:
Hello from OnBeginRequest in custom module.
Hello from MyModule_OnMyEvent called in Global.asax.
Hello from Test.aspx.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900