📄 emails.cs
字号:
messageToFormat = messageToFormat.Replace("<DeleteReasons>", deleteReason);
}
return messageToFormat;
}
// *********************************************************************
// SendMessageApprovedEmail
//
/// <summary>
/// This method sends an email to the user whose post has just been approved.
/// </summary>
/// <param name="PostID">Specifies the ID of the Post that was just approved.</param>
///
// ********************************************************************/
public static void SendMessageApprovedEmail(int postID) {
SendEmail(((Post) Posts.GetPost(postID, null)).Username, EmailTypeEnum.MessageApproved, postID);
}
// *********************************************************************
// SendMessageMovedAndApprovedEmail
//
/// <summary>
/// This method sends an email to the user whose post has just been moved AND approved.
/// </summary>
/// <param name="PostID">Specifies the ID of the Post that was just approved.</param>
///
// ********************************************************************/
public static void SendMessageMovedAndApprovedEmail(int postID) {
// send the email
SendEmail(((Post) Posts.GetPost(postID, null)).Username, EmailTypeEnum.MessageMovedAndApproved, postID);
}
// *********************************************************************
// SendMessageMovedAndNotApprovedEmail
//
/// <summary>
/// This method sends an email to the user whose post has just been moved AND NOT approved
/// </summary>
/// <param name="PostID">Specifies the ID of the Post that was just approved.</param>
///
// ********************************************************************/
public static void SendMessageMovedAndNotApprovedEmail(int postID) {
// send the email
SendEmail(((Post) Posts.GetPost(postID, null)).Username, EmailTypeEnum.MessageMovedAndNotApproved, postID);
}
// *********************************************************************
// SendThreadTrackingEmails
//
/// <summary>
/// This method sends an email to all of those people who have subscribed
/// to track a particular thread. This function is called when a new
/// message is added to the thread.
/// <seealso cref="SendEmail"/>
/// </summary>
/// <param name="postID">The ID of the newly posted message.</param>
/// <remarks>This method first obtains a list of all of those users who are
/// subscribed to track the thread that the new email was added to. It then
/// calls SendEmail, passing along this information.</remarks>
///
// ********************************************************************/
public static void SendThreadTrackingEmails(int postID) {
string bcc = "";
string username;
// Get the username of the currently logged on user
username = Users.GetLoggedOnUser().Username;
// Get the list of user's we will send this mail to
UserCollection users = GetEmailList(postID);
// Add each user to the bcc list
for (int i=0; i < users.Count; i++) {
User user;
// Get a user object
user = (User) users[i];
// ensure we don't send mail to the user that caused
// this action
if (username.ToLower() != user.Username.ToLower())
bcc += user.Email + ",";
}
// send the email
SendEmail("", EmailTypeEnum.NewMessagePostedToThread, postID, bcc);
}
// *********************************************************************
// GetEmailList
//
/// <summary>
/// Retrieves a list of email addresses from the users who are tracking a particular thread.
/// </summary>
/// <param name="PostID">The PostID of the new message. We really aren't interested in this
/// Post, specifically, but the thread it belongs to.</param>
/// <returns>A UserCollection with the email addresses of those who want to receive
/// notification when a message in this thread is replied to.</returns>
///
// ********************************************************************/
private static UserCollection GetEmailList(int postID) {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
return dp.GetEmailList(postID);
}
// *********************************************************************
// GetEmailTemplateList
//
/// <summary>
/// This method returns a list of all of the email templates in the Emails table.
/// </summary>
/// <returns>Returns an EmailTemplateCollection with all of the email templates.</returns>
///
// ********************************************************************/
public static EmailTemplateCollection GetEmailTemplateList() {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
return dp.GetEmailTemplateList();
}
// *********************************************************************
// GetEmailTemplateList
//
/// <summary>
/// This method returns the info for a particular email template.
/// </summary>
/// <param name="emailTemplateID">Specifies the numeric value of the EmailID.</param>
/// <returns>An EmailTemplate containing the information about a particular
/// email template.</returns>
///
// ********************************************************************/
public static EmailTemplate GetEmailTemplateInfo(int emailTemplateID) {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
return dp.GetEmailTemplateInfo(emailTemplateID);
}
// *********************************************************************
// UpdateEmailTemplate
//
/// <summary>
/// This method updates an existing email template.
/// </summary>
/// <param name="email">An email template object containing information on the email template to
/// update.</param>
///
// ********************************************************************/
public static void UpdateEmailTemplate(EmailTemplate email) {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
dp.UpdateEmailTemplate(email);
}
// *********************************************************************
// SendModeratorsNotification
//
/// <summary>
/// Sends those moderators who are assigned to receive email notification an email indicating that
/// a new post has been posted to a forum that they moderate.
/// </summary>
/// <param name="postID">The ID of the newly added post.</param>
/// <remarks>This method should only be called when a new post is added and is awaiting moderation.</remarks>
///
// ********************************************************************/
public static void SendModeratorsNotification(int postID) {
// get a list of moderators who are interested in hearing about the
// particular post
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
UserCollection users = dp.GetModeratorsInterestedInPost(postID);
// loop through each record
String bcc = "";
for (int i=0; i < users.Count; i++)
bcc += ((User) users[i]).Email + ",";
// send the email
SendEmail("", EmailTypeEnum.ModeratorEmailNotification, postID, bcc);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -