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);
     
     
    }
    }
  • 相关阅读:
    Quartz学习笔记
    apache shiro学习笔记
    zTree学习笔记
    WebService学习笔记
    【webservice】Two classes have the same XML type name(转)
    使用OCUpload和POI一键上传Excel并解析导入数据库
    EasyUI学习笔记(四)—— datagrid的使用
    thinkphp的路径问题
    thinkphp验证码不现实多半是bom惹的祸
    TPM(ThinkPHPMobile)使用简明教程
  • 原文地址:https://www.cnblogs.com/csts/p/2456589.html
Copyright © 2011-2022 走看看