Hi All,
Have you ever wanted to programmatically enable receiving of mail on a SharePoint list or library?
Here's how you can accomplish this.
Suppose your domainname is : mydomain.local
// Get the list
{
using (SPWeb web = site.RootWeb)
{
SPList list = web.Lists["Documents"];
// Check if this list is able to receive email. Not all list types are able to receive email.
// Only the following list types are able to receive email:
// - Document, picture, or form library
// - Announcements list
// - Calendar list
// - Discussion board
// - Blog
//
if (list.CanReceiveEmail)
{
// Set 'Allow this document library to receive e-mail?' to YES.
list.EnableAssignToEmail = true;
// Set 'E-mail address:' to the following address
list.EmailAlias = "manuals";
// Don't forget to save the changes you've made
list.Update();
}
}
}
After you've run this code you now can send emails to manuals@mydomain.com
ps. Make sure that you've setup the outgoing/incoming mailsettings in Central Admin -> Operations before running this code!
That's all folks!!!
Ciao,
Niels