Is it possible to add/delete EPiServer mail categories using code?
We're running EPiServer Mail Administration 4.4.343.20 and as far as we can tellyou can only add categories in the admin GUI.
Yes, you can use CategoryHandler in EPiServer Common to do this.
The categories for EPiServer Mail 4.4 are created under the root node (exists each site) named by the value of EPiServerMailModule.Instance.UniqueName.
To get the root node for EPiMail you could do something like
var root = CategoryHandler.GetCategory(theSite, EPiServerMailModule.Instance.UniqueName)
And then use the new Category("mycategoryname", root) constructor to create a new node under it (and commit it using the Add method in CategoryHandler)
Please see the SDK for info on the category system in EPiServer Common (link below is for the version used with Mail 4.4):
(This category structure used in EPiMail has changed slightly in version 5.0 as sites are not part of common there, but the same principle applies that CategoryHandler is used).
and thank you for the answer.
Doesn't EPiServer Common require the EPiServer Community Module?
EPiServer Common is shared between (and ships with) EPiCommunity and EPiMail.
Ah, I see. Thanks!