I was wandering if someone could assist?
I am trying to implement a custom expiration policy within sharepoint, I hope to achieve the ability to get notified when a document reaches its expiration date via email.
I have been attempting to implement this with the following code:
using System.Web;
using Microsoft.SharePoint;
using Microsoft.Office.RecordsManagement;
using Microsoft.Office.RecordsManagement.PolicyFeatures;
using Microsoft.Office.DocumentManagement;
using Microsoft.SharePoint.Utilities;
using System;
namespace ExpirationTest
{
public class FilteredExpiration : IExpirationFormula
{
public DateTime? ComputeExpiteDate(SPListItem item, System.Xml.XmlNode parametersData)
{
//Check if item is in warning period
//If it is, send warning email stating
//that document will expire in a month
DateTime expiryDate = new DateTime();
if (item["_dlc_ExpireDate"] != null)
{
//Get item's expiry date.
expiryDate = (DateTime)item["_dlc_ExpireDate"];
//Find remaining time to expiry
TimeSpan diff = expiryDate.Subtract(DateTime.Now);
//If less then a month, send warning email
if (diff.Minutes <= 2)
SendWarningEmail(item);
}
if (item["CollectMe"].ToString().Equals("True"))
return DateTime.Now;
else
return ((DateTime)item["Modified"]).AddDays(365);
}
private void SendWarningEmail(SPListItem item)
{
try
{
SPSite thisSite = new SPSite("http://sharepoint:14236");
SPWeb thisWeb = thisSite.RootWeb;
string toField = "Alex.Nagy@centraxtcl.com";
string subject = "Test Message";
string body = "Document - " + item.Name + " - will expire in a month.";
HttpContext oldContext = HttpContext.Current;
HttpContext.Current = null;
bool success = SPUtility.SendEmail(thisWeb, true, true, toField, subject, body);
HttpContext.Current = oldContext;
}
catch (Exception ex)
{
//handle exception
}
}
}
}
When attempting to implement this code I get the following error:
Error 1 'ExpirationTest.FilteredExpiration' does not implement interface member 'Microsoft.Office.RecordsManagement.PolicyFeatures.IExpirationFormula.ComputeExpireDate(Microsoft.SharePoint.SPListItem, System.Xml.XmlNode)' C:\Users\Alex.Nagy\Documents\Visual Studio 2010\Projects\ExpirationTest\ExpirationTest\FilteredExpiration.cs 11 18 ExpirationTest
Can anyone help, or suggest an alternate way of doing this?