Friday, April 30, 2010

Truncating SharePoint DB log file

I could free few gig's of space after using the DBCC SHRINKFILE command , give it a try and you will realize the importance

USE DBName
GO
BACKUP LOG DBName WITH TRUNCATE_ONLY
GO
DBCC SHRINKFILE (DBLogFile, 1)
GO
DBCC SHRINKFILE (DBLogFile, 1)
GO
exec sp_helpfile

Friday, April 9, 2010

Pulling the items from the mail server

This is one of the nice features that Exchange has provided. It enables the user to pull the data from the mail box and push the same on other sites, lists, xml file, etc.

A small snippet of the same -
using Microsoft.Exchange.WebServices.Data;

private IList FindItems(DateTime fromDate, int maxItems)
{
SearchFilter.SearchFilterCollection filter = new SearchFilter.SearchFilterCollection();
filter.Add(new SearchFilter.IsGreaterThan(ItemSchema.DateTimeReceived, fromDate));
ItemView view = new ItemView(maxItems);
view.OrderBy.Add(ItemSchema.DateTimeReceived, SortDirection.Descending);
FindItemsResults findResults = _service.FindItems(
new FolderId(WellKnownFolderName.Inbox, _mailAddress),
filter,
view);
//No mails since last time
if (findResults.Count()==0)
{
return null;
}
PropertySet propertiesToLoad = new PropertySet(
ItemSchema.Subject,
ItemSchema.Body,
ItemSchema.DateTimeReceived,
EmailMessageSchema.Sender
);
_service.LoadPropertiesForItems(findResults, propertiesToLoad);
return new List(findResults);
}