none
关于sharepoint里关于工作流发邮件问题 RRS feed

  • 问题

  •        我想做一个提前30天邮件自动提醒的功能,sharepoint中有一个栏位是  “日期” 我 先 获取今天的时间,然后再今天的时间上加30天 如代码  DateTime dt = DateTime.Now;
                dt = dt.AddDays(30); 

      如何与sharepoint中的“日期”栏位作比较呢?   请大家帮忙解决下,非常感谢!!!!!!!!!

      程序里具体代码如下:

     SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (SPSite site = new SPSite(""))
                    {
                        using (SPWeb web = site.OpenWeb())
                        {
                          
                            SPList list = web.Lists[""];
                          
                            SPListItemCollection items = GetItems(list);
                           
                            StringBuilder sb;
                                               foreach (SPListItem item in items)
                            {
                                 mails = new List<string>();

                                 string str = string.Empty;
                               
                                 string[] sjr = { "收件人组" };
                                 foreach (string a in sjr)
                                 {
                                     str = a.ToString();
                                   SPGroup spGroup = null;
                                     try
                                     {
                                         spGroup = web.Groups[str];
                                     }
                                     catch { }
                                     if (spGroup != null)
                                     {
                                         foreach (SPUser spUser in spGroup.Users)
                                         {
                                             if (!string.IsNullOrEmpty(spUser.Email))
                                               
                                             mails.Add(spUser.Email);
                                         }
                                     }
                                 }
                              
                                sb = new StringBuilder();
                                                         
                                sb.Append("<H1><font color='blue'>证件有效期即将到期</font></H1>");
                                sb.Append("<br/><br/>");
                                sb.AppendFormat("原料名称: {0}", item["原料名称"]);
                                sb.Append("<br/>");
                                sb.AppendFormat("购买形式: {0}", item["购买形式"]);
                                sb.Append("<br/>");
                                sb.AppendFormat("证件有效期: {0}", item["证件有效期"]);
                                 sb.AppendFormat("详细情况请点击:<a href='http://*********={0}'>详细信息</a>", item["ID"]);
                                sb.Append("<br/><br/>系统邮件,请勿直接回复!");
                               
                               
                               
                                body = sb.ToString();
                               
                                //Tools.SendMail(title, body, mails.ToArray());

                       }

     


                        }
                      
                    }
                });
            }

            public SPListItemCollection GetItems(SPList list)
            {

                DateTime dt = DateTime.Now;
                dt = dt.AddDays(30);
                SPQuery query = new SPQuery();                  
                string str = "<Query><Where><And><Eq><FieldRef Name='_x8bc1__x4ef6__x6709__x6548__x67' /><Value Type='DateTime'>" + dt + "</Value></Eq></And></Where></Query>";
                  query.Query = str;

                SPListItemCollection items = list.GetItems(query);

                return  items;
            }

          

    2010年8月19日 6:27

答案

全部回复

  • 如果你说的是Item的Create Date,这个很容易取得啊,Create Date貌似不在具体的某个字段里面,需要使用对象模型取得。
    人的强大不是征服了什么,而是承受了什么
    2010年10月12日 7:04
  • 有一个createon

    你可以下载一个camleditor来看看究竟是哪个字段

    2010年10月21日 11:19
    版主