Hi guys,
I had a test the other day and missed a question out because it confused the hell out of me. I dont know if it was a badly written question or just me. Heres the program below:
public static class Mailing
{
public static void SendTestEmail()
{
List<Person> people = new List<Person>();
people.Add(new Person("Joe", "Bloggs", "Joe.Bloggs@foo.bar"));
people.Add(new Person("John", "Smith", "John.Smith@foo.bar"));
people.Add(new Person("Ann", "Other", "Ann.Other@foo.bar"));
string emailSubject = "Training cancellation notification";
string emailText = "Dear user, this is an email to inform you
that your training course on the 1st of January has been cancelled";
SendEmail(emailSubject, emailText, people);
}
private static void SendEmail(string emailSubject, string emailText,
List<Person> people)
{
string emailHost = "smtp.foo.bar";
MailAddress fromAddress = new MailAddress("system@foo.bar");
MailMessage mailing = new MailMessage();
mailing.From = fromAddress;
mailing.Subject = emailSubject;
mailing.To.Add(fromAddress);
foreach (Person person in people)
mailing.Bcc.Add(person.EmailAddress);
mailing.Body = emailText;
SmtpClient client = new SmtpClient(emailHost);
client.Send(mailing);
}
}
public class Person
{
public Person(string firstName, string lastName, string emailAddress)
{
FirstName = firstName;
LastName = lastName;
EmailAddress = emailAddress;
}
string FirstName;
string LastName;
string EmailAddress;
}
The question was - adapt the code to include person specific information in the email, you can re-write any or
all of the supplied code to do this.
Any idea what I was meant to do guys?