Quantcast
Viewing latest article 8
Browse Latest Browse All 9

Re: Emails being sent to strange recipients

In the DoReminderJob method, the template is obtained from a file. Then for each member, a loop runs that replaces some placeholders (##FirstName## and ##DueDate##) with the current member's first name and due date. However, once the replacement has been made for the first member, the placeholders no longer exist for subsequent members, so no replacement is made. You will probably find that it is the same incorrect firstname used in all emails. A quick fix would be to assign the template to a new variable that gets reset for each iteration:

// Replace template with parameters
string body;
foreach (var replacement in replacements)
{
    body = template.Replace(replacement.Key, replacement.Value);
}

//Send the email
var newMail = new Mail();
newMail.FromDisplayName = "CYCANL Admin";
newMail.From = "XXXXX@cycanl.ca";

newMail.SendMail(new[] { email }, "Membership Renewal Reminder", body);


Viewing latest article 8
Browse Latest Browse All 9

Trending Articles