WebMail Pro ASP.NET documentation

Visual integration with your web application

You may need to make WebMail interface a part of your web site interface. For example, if your web site has several sections (e.g. "My Blog", "My Pictures", "My Mail") and a navigation menu which should always stay on the screen (no matter which section is currently selected), WebMail shouldn't overlap the navigation menu and shouldn't be opened in a separate window. To achieve this, you need to place WebMail into an IFRAME which is a part of your interface. Placing WebMail directly into your interface (e.g. into a DIV element) is not possible as it's complex AJAX application which relies to absolute coordinates and has its own system of exchanging XML packets with server. So, an IFRAME is the only way to get it working properly.

How to place WebMail into an IFRAME correctly? The following simple example demonstrates that:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
     <title>iframe test</title>
     <div style="background-color: #EEE; width: 900px;">Your navigation menu here</div><br />
     <iframe src="http://your.webmail.url/" style="width: 900px; height: 600px;"></iframe>

You should change http://your.webmail.url/ URL to the one pointing to your WebMail installation.

Now let's use visual integration along with passing authentication data to WebMail which is described here. First, please create test-iframe.aspx/test-iframe.aspx.cs file and copy/paste the code from Example 4 there, then modify the example to get it working in your environment. It's assumed that you placed that file into the web folder of your ASP.NET application. Now, just add the following line to one of your ASP.NET pages:

<iframe src="test-iframe.aspx" style="width: 900px; height: 600px;"></iframe>

As you can see, it refers to the file with the integration script you created previously. Both test-iframe.aspx and the page you placed the IFRAME to are in the same folder.

Now, you may wonder how to pass authentication data from your ASP.NET application to UserLoginByEmail method called in test-iframe.aspx. Don't pass that data through GET method (in URL after ? char) for security reasons, but use server-side ASP.NET sessions instead. Example:

* A part of default.aspx file:

// Store credentials in session
Session["email"] = "john_doe@mydomain.com";
Session["login"] = "john_doe";
Session["password"] = "mypassword";
<iframe src="test-iframe.aspx" style="width: 900px; height: 600px;"></iframe>

* A part of test-iframe.aspx.cs file:

Integration integr = new Integration(@"C:\WebMail-Pro-Net\data", @"http://www.mydomain.com/WebMail-Pro-Net/");

    integr.UserLoginByEmail(Session["email"], Session["login"], Session["password"], WMStartPage.Mailbox, null);
catch (WebMailException ex)
    Response.Write("Error: failed to log into the account. Reason: " + ex.Message);