internal static void MailSenden(Klasse to, Lehrer bereichsleiter, string subject, string body, List <string> fileNames) { ExchangeService exchangeService = new ExchangeService() { UseDefaultCredentials = true, TraceEnabled = false, TraceFlags = TraceFlags.All, Url = new Uri("https://ex01.bkb.local/EWS/Exchange.asmx") }; EmailMessage message = new EmailMessage(exchangeService); try { foreach (var item in to.Klassenleitungen) { if (item.Mail != null && item.Mail != "") { message.ToRecipients.Add(item.Mail); } } message.CcRecipients.Add(bereichsleiter.Mail); message.BccRecipients.Add("*****@*****.**"); } catch (Exception) { message.ToRecipients.Add("*****@*****.**"); } message.Subject = subject; message.Body = body; foreach (var datei in fileNames) { message.Attachments.AddFileAttachment(datei); //File.Delete(datei); } //message.SendAndSaveCopy(); message.Save(WellKnownFolderName.Drafts); }
internal void AddAppointments( Appointments appointmentsIst, Lehrer lehrer, ExchangeService service) { try { foreach (var appointmentSoll in this) { // Wenn das Soll-Appointment nicht in den Ist-Appointments existiert, ... if (!(from a in appointmentsIst where a.Subject == appointmentSoll.Subject where a.Start == appointmentSoll.Start where a.End == appointmentSoll.End where (appointmentSoll.Categories.Contains("ZulassungskonferenzenBC")) select a).Any()) { // ... wird angelegt service.ImpersonatedUserId = new ImpersonatedUserId( ConnectingIdType.SmtpAddress, lehrer.Mail); appointmentSoll.IsReminderSet = false; appointmentSoll.Save(); Console.WriteLine("[ + ] " + appointmentSoll.Subject.PadRight(30) + appointmentSoll.Start + " - " + appointmentSoll.End); } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); throw new Exception(ex.ToString()); } }
public static string GetAnrede(Lehrer lehrer) { return((lehrer.Anrede == "Frau" ? "Frau" : "Herrn") + " " + lehrer.Titel + (lehrer.Titel == "" ? "" : " ") + lehrer.Nachname); }