When we use the API in the. NET class library to send mail, We need to configure its SMTP server and so on, but in Sharepoint, we have provided the relevant encapsulation methods:
Sputility. sendemail (spweb, false, false, "to@mail.com", "mailtitle", "mailbody ");
The above method can only send mail in the form of to, sometimes we need to use CC, BCC, we can use another overload of this function to achieve:
Sputility. sendemail (Web, messageheaders, messagebody, appendfooter)
We need to set messageheaders,CodeAs follows:
Stringdictionary headers = new stringdictionary ();
Headers. Add ("to", "To@Mail.com ");
Headers. Add ("cc", "CC@Mail.com ");
Headers. Add ("BCC", "BBC@Mail.com ");
Headers. Add ("from", "From@Mail.com ");
Headers. Add ("subject", "The Mail title ");
Headers. Add ("Content-Type", "text/html ");
You can specify to cc bcc from in the header. Of course, the premise of using the above function is that you have configured the outgoing email settings in the management center.