Updating a discussion list entry in sharepoint
I wonder if there might be a way, without creating a custom workflow solution, to allow users subscribing to alerts in a Discussion list to get emails from the list email address (vs the default MOSS/WSS email account) in order to allow users to simply reply back to the email and have it add to the discussion.
A big issue we currently have with users running discussion boards is that people frequently mistake a message as from someone, and automatically hit reply. This results in the email being returned to the system account. Not helpful for the discussion
Answers
Hi kukdai,
You can handle the outgoing part using the methods suggested above.
If the default incoming part does not satisfy your needs, you can create a custom handler for incoming mails too by deriving from the SPEmailEventReceiver class (http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.spemaileventreceiver.aspx). In that you can check the subject of the incoming mail and save the item into the existing thread based on that.
Here are some general post about mail-enabling discussions:
E-mail discussion lists in SharePoint
http://www.coolweblog.com/bilodeau/archives/003211.html
Incoming Email in SharePoint v3
http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=31
WSS 3.0 - Email Enabled Discussion Lists
http://www.tech-archive.net/Archive/SharePoint/microsoft.public.sharepoint.windowsservices/2009-01/msg00127.html
"I will be really grateful to you if it can be happen"
Such things generally does not happen. They must be done by someone.
If you have specific technological questions I try to answer that, or I can give you general ideas, but since I have my full-time job and do this forum only voluntary in my spare time, unfortunately I have no time to implement a mail-based discussion list for you. If you need that feature, either you have to do that, or get (find on the web, buy, have it be done by someone else, probably not for free) it from somewhere.
If you really appreciate my help, and feel that one (or more) of the replies is helpful or answers your question, please mark it as such. If you need more help on the topic, please, let me know how I can help you!Thanks!
Peter
- Marked As Answer bykukdai Thursday, October 29, 2009 6:26 PM
All Replies
Hi,
I think that none of the following is (or much) easier than a custom workflow, but you requested a solution without workflow and not an easier one:
Option A.
You can create an event receiver for the discussion list and send the mail from that using the list mail address as reply to address. Here you should handle the subscription issue too (e.g. look up users being subscribed to the discussion list).
For a general help about event receivers
Walkthrough 1 – Developing a Simple Event Receiver
http://karinebosch.wordpress.com/walkthroughs/event-receivers-walkthrough1/Wrox Article Programming Event Handling in Windows SharePoint Services
http://www.wrox.com/WileyCDA/Section/Programming-Event-Handling-in-Windows-SharePoint-Services.id-306329.htmlBrian Wilson's Blog Event Handlers - Part 1 Everything you need to know about Microsoft Office SharePoint Server (MOSS) Event Handlers. (see other parts too)
http://blogs.msdn.com/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-you-need-to-know-about-microsoft-office-sharepoint-portal-server-moss-event-handlers.aspxEvent Receivers - SharePoint Development Wiki - SharePoint Dev Wiki
http://sharepointadminwiki.com/display/public/Event+Receivers?focusedCommentId=8519834Option B.
Create custom IAlertNotifyHandler and send the mails from that.
How To: Customizing alert emails using IAlertNotifyHandler
http://blogs.msdn.com/sharepointdeveloperdocs/archive/2007/12/14/how-to-customizing-alert-emails-using-ialertnotificationhandler.aspx
Custom Alert Handlers: Part 1 of 2
http://blogs.syrinx.com/blogs/sharepoint/archive/2008/04/28/custom-alert-handlers-part-1-of-2.aspx
Option C.
Custom SMTP event receiver. On the ongoing mail you can check the subject, and if the mail is from the discussion list you can replace the sender and / or the reply-to address on the flight.
Sorry, but I'm afraid it does not help you too much.
Peter- hey peter awesome man,
how can it be done through a custom workflow i can send emails through custom workflow but will it sends email from the sharepoint list's email address
and once my user gets the alerts can his reply be addeed to the current item not as a new entry but just append to the current item. I will be really grateful to you if it can
be happen. I will convince them to use a custom workflow. but i am stucked in the point if the reply can be added to the current item in the discussion list as a reply entry..
I really appreciate your help man i dont have any words to thank you Hi kukdai,
You can handle the outgoing part using the methods suggested above.
If the default incoming part does not satisfy your needs, you can create a custom handler for incoming mails too by deriving from the SPEmailEventReceiver class (http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.spemaileventreceiver.aspx). In that you can check the subject of the incoming mail and save the item into the existing thread based on that.
Here are some general post about mail-enabling discussions:
E-mail discussion lists in SharePoint
http://www.coolweblog.com/bilodeau/archives/003211.html
Incoming Email in SharePoint v3
http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=31
WSS 3.0 - Email Enabled Discussion Lists
http://www.tech-archive.net/Archive/SharePoint/microsoft.public.sharepoint.windowsservices/2009-01/msg00127.html
"I will be really grateful to you if it can be happen"
Such things generally does not happen. They must be done by someone.
If you have specific technological questions I try to answer that, or I can give you general ideas, but since I have my full-time job and do this forum only voluntary in my spare time, unfortunately I have no time to implement a mail-based discussion list for you. If you need that feature, either you have to do that, or get (find on the web, buy, have it be done by someone else, probably not for free) it from somewhere.
If you really appreciate my help, and feel that one (or more) of the replies is helpful or answers your question, please mark it as such. If you need more help on the topic, please, let me know how I can help you!Thanks!
Peter
- Marked As Answer bykukdai Thursday, October 29, 2009 6:26 PM
Hi Peter,
this is the updating Hnadler Code here how would i add the reply2 address as the email address of the current list
so that when user hit reply to the alert then at replyaddress the list email address should automatically populated...
as like
when i hit reply to an email
in the to address i see the email address of the sender.. Like This
I tried to add but its not working..
Below is the Code How you add a From address here so it would be the reply 2 address...
//===================code start=====================
public class Class1:IAlertNotifyHandler
{#region IAlertNotifyHandler Members
public bool OnNotification(SPAlertHandlerParams ahp)
{
SPSite site = null;
SPWeb web = null;try
{
site = new SPSite(ahp.siteUrl+ahp.webUrl);
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 = "<style type=\"text/css\">.style1 { font-size: small; border: 1px solid #000000;"+
"background-color: #DEE7FE;}.style2 { border: 1px solid #000000;}</style></head>"+
"<p><strong>"+ item.Name.ToString() +"</strong> has been "+eventType +"</p>"+
"<table style=\"width: 100%\" class=\"style2\"><tr><td style=\"width: 25%\" class=\"style1\">"+
"<a href="+ webPath +"/_layouts/mysubs.aspx>Modify my Settings</a></td>"+
"<td style=\"width: 25%\" class=\"style1\"> <a href="+ FullPath +">View "+item.Name+"</a></td>"+
"<td style=\"width: 25%\" class=\"style1\"><a href=" + ListPath + ">View " + list.Title + "</a></td>" +
" </tr></table>";
string subject=list.Title.ToString() ;
string ReplyEmail=list.email.ToString();
ahp.headers.add("from",ReplyEmail);
SPUtility.SendEmail(web,true , false, ahp.headers["to"].ToString(),ahp.headers["From"].ToString(), subject,build);(how to add a from address here so it can be a reply 2 address)
return false;
}
catch (System.Exception ex)
{
return false;
}
finally
{
if (web != null)
web.Dispose();
if (site != null)
site.Dispose();
}}
#endregion
- Hi,
I don't know SPUtility.SendEmail method overload that has parameter pattern you would like to use:
SPWeb, bool, bool, string, string, string, string
See the thread below for an example how to set the From address:
How to give From Address in the SPUtility.SendEmail?
http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/b9f897c0-dddb-4702-80ca-60cccf368ddf
Hope that helps.
Peter - Hi Peter,
I am modified the above code and it works the way i wanted it sends alert from my list's email address. But I dont get alerts when i add posted a reply to an item in Discussion List or when an item is deleted i get alerts only when a new item is added... Below is the code I am working:::
<strong>using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.SharePoint; using Microsoft.SharePoint.Utilities; using System.Web; using System.Collections.Specialized; using Microsoft.SharePoint.Administration; namespace CustomTemplate { //===================code start===================== public class Class1 : IAlertNotifyHandler { #region IAlertNotifyHandler Members public bool OnNotification(SPAlertHandlerParams ahp) { SPSite site = null; SPWeb web = null; string eventtype = ""; try { site = new SPSite(ahp.siteUrl + ahp.webUrl); web = site.OpenWeb(); SPList list = web.Lists[ahp.a.ListID]; SPListItem item = list.GetItemById(ahp.eventData[0].itemId); StringDictionary headers = new StringDictionary(); 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 from =list.EmailAlias+"@"+"sharepointsb.3par.com"; string build = ""; if (ahp.eventData[0].eventType == 1) { eventtype = "Added"; build = "<style type=\"text/css\">.style1 { font-size: small; border: 1px solid #000000;" + "background-color: #DEE7FE;}.style2 { border: 1px solid #000000;}</style></head>" + "<p><strong>" + item.Name.ToString() + "</strong> has been " + eventtype + "</p>" + "<table style=\"width: 100%\" class=\"style2\"><tr><td style=\"width: 25%\" class=\"style1\">" + "<a href=" + webPath + "/_layouts/mysubs.aspx>Modify My Alerts</a></td>" + "<td style=\"width: 25%\" class=\"style1\"> <a href=" + FullPath + ">View " + item.Name + "</a></td>" + "<td style=\"width: 25%\" class=\"style1\"><a href=" + ListPath + ">View " + list.Title + "</a></td>" + " </tr></table>"; string subject = item.Name.ToString(); headers.Add("subject", subject); headers.Add("from", from); headers.Add("to", ahp.headers["to"].ToString()); SPUtility.SendEmail(web, headers, build); } else if (ahp.eventData[0].eventType == 2) { eventtype = "Changed"; build = "<style type=\"text/css\">.style1 { font-size: small; border: 1px solid #000000;" + "background-color: #DEE7FE;}.style2 { border: 1px solid #000000;}</style></head>" + "<p><strong>" + item.Name.ToString() + "</strong> has been " + eventtype + "</p>" + "<table style=\"width: 100%\" class=\"style2\"><tr><td style=\"width: 25%\" class=\"style1\">" + "<a href=" + webPath + "/_layouts/mysubs.aspx>Modify My Alerts</a></td>" + "<td style=\"width: 25%\" class=\"style1\"> <a href=" + FullPath + ">View " + item.Name + "</a></td>" + "<td style=\"width: 25%\" class=\"style1\"><a href=" + ListPath + ">View " + list.Title + "</a></td>" + " </tr></table>"; string subject = item.Name.ToString(); headers.Add("subject", subject); headers.Add("from", from); headers.Add("to", ahp.headers["to"].ToString()); SPUtility.SendEmail(web, headers, build); } else if (ahp.eventData[0].eventType == 3) { eventtype = "Deleted"; build = "<style type=\"text/css\">.style1 { font-size: small; border: 1px solid #000000;" + "background-color: #DEE7FE;}.style2 { border: 1px solid #000000;}</style></head>" + "<p><strong>" + item.Name.ToString() + "</strong> has been " + eventtype + "</p>" + "<table style=\"width: 100%\" class=\"style2\"><tr><td style=\"width: 25%\" class=\"style1\">" + "<a href=" + webPath + "/_layouts/mysubs.aspx>Modify My Alerts</a></td>" + "<td style=\"width: 25%\" class=\"style1\"> <a href=" + FullPath + ">View " + item.Name + "</a></td>" + "<td style=\"width: 25%\" class=\"style1\"><a href=" + ListPath + ">View " + list.Title + "</a></td>" + " </tr></table>"; string subject = item.Name.ToString(); headers.Add("subject", subject); headers.Add("from", from); headers.Add("to", ahp.headers["to"].ToString()); SPUtility.SendEmail(web, headers, build); } //SPUtility.SendEmail(web, true, false, ahp.headers["to"].ToString(), subject, build); return false; } catch (System.Exception ex) { return false; } finally { if (web != null) web.Dispose(); if (site != null) site.Dispose(); } } #endregion } }</strong>

