How to configure your MyInbox webpart automatically ?

本文提供了一种方法,通过自动配置Web部件库项目来简化SharePoint Outlook Web部件的配置过程,确保每个用户都能成功配置MyInbox。

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 moments' *d'oh*

So, here's the one and only, the solution !

Follow the autoConfig lab below 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 particular 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 to
// 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 !


转载于:https://www.cnblogs.com/ahghy/archive/2012/12/25/2831918.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值