private void printschedule(Christmaslocation schedulelist) { string line; List <SantaGift> Slist = new List <SantaGift>(); System.IO.StreamReader Wishfile = new System.IO.StreamReader(@"C:\Users\BlooddSkullKing\source\repos\school\SecretSanta\wishlist.txt"); while ((line = Wishfile.ReadLine()) != null) { Slist.Add(new SantaGift() { name = line, location = Wishfile.ReadLine(), Pricelimit = Wishfile.ReadLine(), Listfile = Wishfile.ReadLine(), Giftcards = Wishfile.ReadLine(), Santaemail = Wishfile.ReadLine() }); } Wishfile.Close(); for (int e = 0; e < Slist.Count; e++) { MailMessage mail = new MailMessage("*****@*****.**", Slist[e].Santaemail, "Christmas Schedule", "The location is at" + schedulelist.Location + "\n" + schedulelist.Time + "\n" + schedulelist.Familyattendance + "\n" + schedulelist.GrandmaAttender); SmtpClient client = new SmtpClient("smtp.gmail.com"); client.Port = 587; client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "secretsanta123"); client.EnableSsl = true; client.Send(mail); } }
private void schedulebutton_Click(object sender, EventArgs e) { Christmaslocation Clocation = new Christmaslocation() { Location = Placebox.Text, Time = Timebox.Text, Familyattendance = Attendancebox.Text, GrandmaAttender = Folksbox.Text }; printschedule(Clocation); }