Ok so i have already read all of these articles:
Best Practices: Using Disposable Windows SharePoint Services Objects
SharePoint 2007 and WSS 3.0 Dispose Patterns by Example
Disposing SPWeb and SPSite objects
SharePoint 2010 - Do not dispose guidance for SharePoint objects
But there's one more thing i would like to know. Should i dispose "site" object referenced below? One of articles above explains that we dont have to dispose *.ParentWeb. The other one states that all objects created using event properties object, shouldnt be disposed. So what should i do in this particular case? Dispose or not? :)
SPSite site = null;
public override void EmailReceived(SPList list, SPEmailMessage emailMessage, String receiverData)
{
base.EmailReceived(list, emailMessage, receiverData);
site = list.ParentWeb.Site;
//some code here
try
{
//some code here
}
catch() {}
finally
{
if(site!=null) site.Dispose();
}
}
//other methods where im using site object