I've got a requirement to allow users to approve or disapprove certain actions by replying to auto generated emails. I've already got a good handle on how to use email enabled lists and event receivers to do this, but what I can't figure out is how to spin up an email enabled list in a feature receiver. I'd rather not have any manual deployment steps for this solution. Is there a good way to enable incoming email for a document library via code?

EDIT: Tried the proposed solution below but still run into some issues. It compiled but the email never showed up in the library. Here's the code I used to generate the list

public override BaseListGenerator GenerateList(Microsoft.SharePoint.SPWeb web)
            _list = web.Lists.TryGetList(title);
            if (_list == null)
                var listId = web.Lists.Add(title, "", SPListTemplateType.DocumentLibrary);
                _list = web.Lists[listId];

           _list.EmailAlias = "isourcingapprovals";

            int numRecieversRegistered = _list.EventReceivers.Cast<SPEventReceiverDefinition>().Where(d => d.Class == typeof(ApprovalEmailEventReciever).FullName).Count();

            if (numRecieversRegistered == 0)
                _list.EventReceivers.Add(SPEventReceiverType.EmailReceived, Assembly.GetExecutingAssembly().FullName, typeof(ApprovalEmailEventReciever).FullName);

            return this;

UPDATE: I resolved this issue too. See the comment on the accepted answer

1 Answer 1


All you need to do is set the EmailAlias to the list.

  • sorry it's been a while ago that i've done this. Normally EmailAlias is all you need to set. There are some more advanced properties that could be set to so check out the second article i posted now. Oct 31, 2011 at 20:00
  • I take it back I'm still running into issues. The email is never showing up in the library. I had this working with a manually generated library, so I'm pretty certain my general settings are right. Also, I can see the email hitting the SMTP drop folder and then disappearing after a few minutes. Interestingly the code generated document library does not have the same options as a manually generated one.I added the code I used to generate the list as an edit. Oct 31, 2011 at 20:39
  • I figured out the issue, per this link blogs.msdn.com/b/malag/archive/2009/05/13/…. I had created and attached my own event reciever in my code, not realizing this event reciever would fire before emails were added to the list. I thought it would fire after sharepoint had already added things to the list. Also SharePoint hides all the options when you have your own reciever attached Nov 2, 2011 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.