zoukankan      html  css  js  c++  java
  • Get SPUserField value

    public string GetAdminEmailAddress(string room)

            {

                string userEmail = string.Empty;

                using (SPSite site = new SPSite(Config.URL))

                {

                    using (SPWeb web = site.OpenWeb())

                    {

                        SPList list = web.Lists[Config.MeetingRoomTitle];

                        SPQuery query=new SPQuery();

                        string camlQuery = string.Format(@"

                                 <View>

                                    <Query>

                                        <Where>

                                                 <Eq>

                                                        <FieldRef Name='Title'/>

                                                        <Value Type='Text'>{0}</Value>

                                                  </Eq>

                                        </Where>

                                     

                                    </Query>

                                </View>", room);

                        query.Query=camlQuery;

                        SPListItemCollection items = list.GetItems(query);

                        try

                        {

                            SPListItem item = items[0];

                            object userField = item["Admin"];

                            if (null != userField)

                            {

                                SPFieldUserValue userValue = new SPFieldUserValue(web, userField.ToString());

                                SPUser user = userValue.User;

                                userEmail = user.Email;

                            }

                        }

                        catch (Exception ex)

                        {

                            Response.Write("Error: "+ex.Message);

                        }

                        return userEmail;

                    }

                }

            }

  • 相关阅读:
    Linux 安装Python3.7
    Linux 修改默认yum源为阿里云
    Linux 安装和配置ActiveMQ Artemis
    Linux 查看内存空间、磁盘空间、进程等信息
    Linux 查询和开启端口
    伤害 等待互斥锁
    深入理解Linux内核之脏页跟踪
    基础——SPI与QSPI的异同,QSPI的具体协议是什么,QSPI有什么用
    浅谈显示器色域:从sRGB到广色域
    Linux SPI 驱动
  • 原文地址:https://www.cnblogs.com/csts/p/2505766.html
Copyright © 2011-2022 走看看