« powrót

Wysyłanie wiadomości email przez Sharepoint [Sharepoint / C#]

Opublikowano: 2011-09-24 , wyświetlono: 11319

Wywołanie


SendEmail("sharepoint@sharepoint.domain.com", "jacek@sharepoint.domain.com", 
  "", "email od sharepoint'a", "<p>wiadomość</p>");


using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;

public static void SendEmail(string from, string to, string cc, string subject, string message)
{
    SPContext currentContext = SPContext.Current;
    SPWeb web = currentContext.Web;

    StringDictionary headers = new StringDictionary();

    headers.Add("to", to);
    if (_userCc.Length > 0)
         headers.Add("cc", cc);
    headers.Add("from", from);
    headers.Add("subject", subject);
    headers.Add("content-type", "text/html");

    SPUtility.SendEmail(web, headers, _message);
}



Komentarze: