Recently, I have seen a lot of discussions on forums about showing user's mailbox on a portal homepage. This is very similar to the case in My Site, but in this case the portal is not My Site and the requirement is to let each user view his/her mailbox using the My Inbox Web Part.
Interestingly, I have seen developers writing custom Web Part for this requirement. In-fact, this is available totally out of the box.
If you are using Exchange 2007, you can just fill in the Exchange Server field in your Outlook Web Parts for MOSS 2007 and the Web Part will pickup the current user's mailbox automatically.
If you have a Exchange 2003 and SharePoint in your organization, this is one of the strong reason alone for going into Exchange 2007 upgrade, along with other benefits which Exchange 2007 provides.
However, If you are using Exchange 2003 and want to achieve this functionality, its easy to write the custom Web Part which automatically assigns the current user and exchange server to Web Part programmatically. But there are limitations of this approach which I will outline at the end of this post. This is simple code for the Web Part which can be used to assign the username and server name.
public class MyInboxEx : System.Web.UI.WebControls.WebParts.WebPart
protected override void CreateChildControls()
//Create the instance of My Inbox Web Part
OWAInboxPart inbox = new OWAInboxPart();
//Get and Assign the server name from web.config
inbox.OWAServerAddressRoot = ConfigurationSettings.AppSettings["SERVER_NAME"];
string userName = Page.Request.ServerVariables["LOGON_USER"];
string mailboxName = userName;
int pos = userName.IndexOf("\\");
if (pos > -1)
mailboxName = userName.Substring(pos + 1);
//Assign the mailbox name
inbox.MailboxName = mailboxName;
In the above code, we can retrieve the server name of exchange server from any configuration store, I am using web.config <AppSettings> section here. Before using this code in any environment, its important to realize its limitations:
- The Web Part makes the assumption that the name of the mailbox is same as the username. Although, this is true for most of Exchange deployments, this is not true for all. I have seen deployments, where FirstName.LastName is used as name of the mailbox while username is entirely different.
- In large Exchange deployments, there are multiple servers being used, and user's mailbox is located to geographically closest server. The Web Part does not take into account of this as we are using single hard coded server name for all the users.
Due to the reasons cited above, the usage of this approach is very limited to small deployments. I have seen this approach being used in one of the deployment at a University 🙂