zoukankan      html  css  js  c++  java
  • SPUtility.SendEmail

    First, in a feature receiver, I swapped the Event content type with the Schedule content type to take advantage of the Attendees field (and the cool Free/Busy field!):

    SPList list = lists["Calendar"];
    SPContentType newContentType =
        list
    .ContentTypes.Add(list.ParentWeb.ContentTypes[SPBuiltInContentTypeId.Schedule]);
    SPContentType oldContentType = list.ContentTypes[0];
    string name = oldContentType.Name;
    string description = oldContentType.Description;
    oldContentType
    .Delete();
    newContentType
    .Name= name;
    newContentType
    .Description= description;
    newContentType
    .Update();

    The form now looks like this:

    enter image description here

    Second, I added an Event Receiver that sends the notices:

    publicoverridevoidItemAdded(SPItemEventProperties properties)
    {
       
    SPList list = properties.List;
       
    SPListItem item = properties.ListItem;
     
     
    SPFieldUserValueCollection values = item[SPBuiltInFieldId.ParticipantsPicker]asSPFieldUserValueCollection;

       
    List<string> emails =newList<string>();
       
    foreach(SPFieldUserValue value in values)
       
    {
           
    SPUser user = value.User;
         
     
    if(!string.IsNullOrEmpty(user.Email))
       
       
    {
                emails
    .Add(user.Email);
           
    }
     
     
    }

       
    if(emails.Count>0)
       
    {
         
     
    StringDictionary headers =newStringDictionary();
       
        headers
    .Add("to",string.Join(";", emails.ToArray()));
         
      headers
    .Add("subject", item.Title);
         
     
    SPUtility.SendEmail(web, headers, body);
     
     
    }
    }
  • 相关阅读:
    java IO流详解
    java设计模式之单例模式(几种写法及比较)
    JS定时刷新页面及跳转页面
    遍历map的四种方法
    String 中去掉空格
    TSP问题_遗传算法(STL大量使用)
    无向图的深度优先生成树和广度优先生成树
    Prim算法求最小生成树
    哈夫曼编码_静态库
    中序线索化二叉树
  • 原文地址:https://www.cnblogs.com/csts/p/2456589.html
Copyright © 2011-2022 走看看