public class Class1:IAlertNotifyHandler
{
#region IAlertNotifyHandler Members
public bool OnNotification(SPAlertHandlerParams ahp)
{
try
{
SPSite site = new SPSite(ahp.siteUrl+ahp.webUrl);
SPWeb web = site.OpenWeb();
SPList list=web.Lists[ahp.a.ListID];
SPListItem item = list.GetItemById(ahp.eventData[0].itemId) ;
string FullPath=HttpUtility.UrlPathEncode(ahp.siteUrl+""+ahp.webUrl+""+list.Title+""+item.Name);
string ListPath = HttpUtility.UrlPathEncode(ahp.siteUrl + "" + ahp.webUrl + "" + list.Title);
string webPath=HttpUtility.UrlPathEncode(ahp.siteUrl+""+ahp.webUrl);
string build = "";
if (ahp.eventData[0].eventType==1)
eventType="Added";
else if(ahp.eventData[0].eventType==2)
eventType="Changed";
else if(ahp.eventData[0].eventType==3)
eventType="Deleted";
build = ""+
"
"+ item.Name.ToString() +" has been "+eventType +"
"+"
"+
"Modify my Settings | "+
View "+item.Name+" | "+View " + list.Title + " | " +
string subject=list.Title.ToString() ;
SPUtility.SendEmail(web,true , false, ahp.headers["to"].ToString(), subject,build);
return false;
}
catch (System.Exception ex)
{
return false;
}
}
#endregion
}
You can put your questions/Suggestions in the comment section, I w ill try to respond as soon as possible.
Thanks,
Sanjay
2 comments:
the event number for Delete = 3 is it correct i dont get delete alerts when i tried to modify my alerts i get alerts for changed and added......
i tried debugging with owstimer.exe
it executes the dll i mean code in other events but in case of deleted items it says::
A first chance exception of type 'System.ArgumentException' occurred in Microsoft.SharePoint.dll
The program '[6592] OWSTIMER.EXE: Managed' has exited with code 0 (0x0).
The program '[6592] OWSTIMER.EXE: T-SQL' has exited with code 0 (0x0).
Any Idea Why it is Happening
Post a Comment