How to configure your myinbox webpart automatically?
It seems to be so difficult to configure your SharePoint outlook webparts automatically, but It isn' t!
Last week, I tried everything, but I failed to configure those outlook webparts.
It seems to be nobody wants to configure a myinbox automatically for every user on the mysite. I didn't found any website or blog with information, I just found some questions on forums without an answer.
So, can I conclude that every user must know the servername and his mailboxname?
No, it's irrealistic in my opinion!
This morning, I had 'one of my famous intelligent mosion'* D' oh *
So, here's the one and only, the solution!
FollowAutoConfig LabBelow to succeed the configuration for every user at runtime
1. Create a New webpart Library Project
2. Override the createchildcontrols
// Import section
Using Microsoft. Sharepoint. Portal. webcontrols;
// Attributes
Private owainboxpart wpinbox;
Protected override void createchildcontrols ()
{
// Inbox webpart
Wpinbox = new owainboxpart ();
Controls. Add (configureinbox (wpinbox ));
}
3. Create a new method to configure your inbox webpart. This method will determine the mailboxname and the servername at runtime for a particle user.
Private owainboxpart configureinbox (owainboxpart wpinbox)
{
// Connect to the portal and get the portal context.
Topologymanager topology = new topologymanager ();
Portalsite portal = topology. portalsites [New uri (http ://Servername)];
Portalcontext context = portalapplication. getcontext (portal );
// Initialize user profile config manager object
Userprofilemanager profilemanager = new userprofilemanager (context );
USERPROFILE Prof = profilemanager. getuserprofile (true );
// Use the profile object to retrieve the properties you need in your company
// Retrieve the mailboxname
// Example: String workmail = Prof [propertyconstants. workemail]. tostring ();
Wpinbox. mailboxname = "kristofdc ";
Wpinbox. owaserveraddressroot = "http ://Servername/Exchange ";
Return wpinbox;
}
4. Override the renderwebpart Method
Protected override void renderwebpart (htmltextwriter output)
{
Try
{
Wpinbox. rendercontrol (output );
}
Catch (exception ex)
{
Output. Write (ex. tostring ());
}
}
5. And finally you will add a cab-setup for your custom webpart.
6. Just compile, deploy and use!
Remarks:
This myinbox example works also with the mycalendar & mytasks.
Success garanteed!