Explaining the emails.xml override file Wednesday, November 14 2007
I received a comment from Robert McLaws on my post Sending Emails in Community Server:
Can you explain a little more about the override file? Does it have to go in the root of CS? If it's an override, why doesn't it use XSLT like the other override files, and why isn't it named emails_override.xml?
I think they're very valid questions, and I'll attempt to answer them here. The answer to the first question "Does it have to go in the root of CS" is very much yes. The logic that gets the file searches only at the root of the web so there's no way to place the file anywhere else within your site as you can see from the code below.
if(File.Exists(csContext.PhysicalPath("emails.xml"))) f = new FileInfo(csContext.PhysicalPath("emails.xml"));
However, the method LoadEmailTemplates() is in the XmlEmailTemplateProvider class and as the name would suggest, it's a provider so you could write your own. You could even write a provider to store the email templates in the DB.
I can't answer the question "why doesn't it use XSLT like the other override files" officially, but in my opinion, that approach wouldn't be needed here. It simply tries to find the email template in that file and if it's not found, it will then search in the normal place. I can't see that the XSLT approach would work well here.
Finally, I'm not sure there's any reason to name it emails_override.xml other than for consistency but really, it's not a .config file so I don't think that's a strong argument. Seeing as the override file and the original file(s) will be in different locations there are no issues with the files having the same name.








Thanks Rich, that helps a lot! The reason I asked is because I built my own CSModule that sends out notifications, and I edited the e-mail template file manually, not knowing about the override file. Now I can fix it so no editing is required. Thanks!