This project is read-only.

New comment emails

Topics: ASP.NET 2.0, Business Logic Layer
Sep 29, 2009 at 7:45 PM

We have multiple authors on a blog inside our firewall.  I have the "send comment e-mail" setting checked, and the e-mails come to the admin address specified on the settings page. However, we would prefer that each author/editor moderate their own comments. That is the behavior I expected, since I need to add the editor e-mail when I set up their account. I do not want to handle all of their comments for them. Is there a way to do this?

Sep 30, 2009 at 5:07 AM

You can modify the SendCommentMail.cs extension in the App_Code\extensions folder.

Check out the November 8th post in this thread (last message) for an idea on how to implement this.

Oct 1, 2009 at 7:56 PM

Thanks for the reply, but when I try that change, it hangs on the saving comment gif. The comment does get written to the XML file, but no "thanks for the comment" message ever appears, and no emails go out.
I tried the blog.js change described in this thread: but it made no difference.
I had earlier edited blog.js and User controls/CommentView.ascx to allow people to comment without providing their e-mail address. I thought that might be part of the issue, so I did a clean installation of BE on my test server. The only code edit I did was the suggestion on this thread and the problem with the saving comment gif hanging appeared immediately. As soon as I restored the code to its original state, the problem went away.

I am running on XP, IIS 5.1, ASP.NET 2.0.50727

Thanks again,

Oct 2, 2009 at 12:07 AM

Did you create a Profile for each author and enter the author's email address in the profile?  That's what the code is dependent on.

Oct 2, 2009 at 7:57 PM

Yes, I used one e-mail address on the BE settings tab, a different address  for the "admin" user account, and created a test admin/editor account with a third e-mail address. Using the "Test mail settings" on the settings tab is always successful, and if I use the default SendCommentMail.cs the notifications will always go to the address on the BE settings tab. But, if I try to make this change to SendCommentMail.cs

<!-- BODY { FONT-FAMILY:Tahoma; FONT-SIZE:10pt } P { FONT-FAMILY:Tahoma; FONT-SIZE:10pt } DIV { FONT-FAMILY:Tahoma; FONT-SIZE:10pt } TD { FONT-FAMILY:Tahoma; FONT-SIZE:10pt } -->         mail.From = new MailAddress(from, HttpUtility.HtmlDecode(comment.Author));

the comment will hang, every time. As I mentioned, the comment gets written to the XML file, but no e-mail is sent and the saving comment GIF animation never stops.

I tested this multiple times, changing the e-mail addresses around between the different accounts to test if BE was having trouble reaching any of the e-mail accounts, but that didn't seem to make a difference. (Two of the addresses were on our system, the third was a Gmail address.)




Oct 3, 2009 at 12:37 AM

Hi Jim, in your reply, you never mentioned the keyword PROFILE.

In the control panel, there's a Users tab and there's a Profiles tab -- two different things.

The code you are adding into SendCommentMail.cs is attempting to look up the PROFILE of the author to retrieve the email address of the author.  This is separate from the email address you define on the Users tab.

After creating a User account, you should then go to the PROFILES tab, and create a PROFILE for the User.  The only field that really needs to be filled in for that User is their email address.

If you want to make the code a little more robust so it doesn't fail when a PROFILE hasn't yet been created, you can use this code instead:

        AuthorProfile authorProfile = post.AuthorProfile;
        if (authorProfile != null && !string.IsNullOrEmpty(authorProfile.EmailAddress))

This would replace the existing line that was originally in SendCommentMail.cs:

Oct 5, 2009 at 7:24 PM

Ben, thanks for clearing that up. Having one email field for the user account and a second one for the profile was confusing, but now I see it and everything seems to be working properly.

One thing that still concerns me (I think someone already has a thread about this) is that editors cannot approve comments to their own posts. I will have to give them admin rights to do that, it seems. That would allow them to do any other admin tasks, so I hope they are all trustworthy.

Jim Reed



Oct 6, 2009 at 2:57 AM

Editors should be able to approve comments to their own posts.  I just tried it with success (only having Editor privileges).

Do you not have an Approve link as an editor, or ... ?

Oct 6, 2009 at 5:17 PM

Yes, I see it now, of course. I could have sworn that when I was testing last week the approve link only appeared when I was logged in as an admin, not as an editor.

Thanks again for the help, Ben. I'm very happy I chose BE.