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);
     
     
    }
    }
  • 相关阅读:
    2019-9-2-一个好的程序员
    2019-9-2-一个好的程序员
    2018-2-13-wpf-GifBitmapDecoder-解析-gif-格式
    2018-2-13-wpf-GifBitmapDecoder-解析-gif-格式
    2019-5-31-SharpDx-进入全屏模式
    2019-5-31-SharpDx-进入全屏模式
    2019-8-31-dotnet-删除只读文件
    2019-8-31-dotnet-删除只读文件
    PHP mysqli_real_connect() 函数
    PHP mysqli_query() 函数
  • 原文地址:https://www.cnblogs.com/csts/p/2456589.html
Copyright © 2011-2022 走看看