How to configure your myinbox webpart automatically?

Source: Internet
Author: User
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.