/// <summary> /// Sends a Reminder Email to a Partner. /// </summary> /// <param name="APartnerReminderDR">DataRow containing the Reminder data.</param> /// <param name="AReadWriteTransaction">Already instantiated DB Transaction.</param> /// <returns>True if the sending of the Reminder Email succeeded, otherwise false.</returns> private static bool SendReminderEmail(PPartnerReminderRow APartnerReminderDR, TDBTransaction AReadWriteTransaction) { string Subject = ""; string Body = ""; string Destination = APartnerReminderDR.EmailAddress; string PartnerShortName; char LF = Convert.ToChar(10); // Retrieve ShortName of the Partner to which the Reminder Email should be sent PartnerShortName = GetPartnerShortName(APartnerReminderDR.PartnerKey); // Format Email Recipient Address as per email RFC's if (!Destination.Trim().StartsWith("<")) { Destination = "<" + Destination; } if (!Destination.Trim().EndsWith(">")) { Destination = Destination + ">"; } // Compose Email Subject Subject = String.Format("OpenPetra Reminder about {0}", PartnerShortName); /* * Compose Email Body */ Body = string.Format("Partner: {0} [{1:0000000000}]{2}", PartnerShortName, APartnerReminderDR.PartnerKey, LF); if (APartnerReminderDR.ContactId != 0) { Body += GetContactDetails(APartnerReminderDR.ContactId, AReadWriteTransaction); } Body += String.Format("Reason: {0}{1}", APartnerReminderDR.ReminderReason, LF); if (!APartnerReminderDR.IsEventDateNull()) { Body += String.Format("Event Date: {0}{1}", StringHelper.DateToLocalizedString(APartnerReminderDR.EventDate), LF); } Body += String.Format("Comment: {0}{1}", APartnerReminderDR.Comment, LF); Body += String.Format("{0}Next Reminder: {1}{2}", LF, StringHelper.DateToLocalizedString(APartnerReminderDR.NextReminderDate), LF); if (APartnerReminderDR.ReminderActive == false) { Body += String.Format("This Reminder has now been disabled.{0}", LF); } // Send Email (this picks up the SMTPServer AppSetting from the Server Config File) return(new TSmtpSender().SendEmail(Destination, "OpenPetra Server", Destination, Subject, Body)); }
/// <summary> /// Sends a Reminder Email to a Partner. /// </summary> /// <param name="APartnerReminderDR">DataRow containing the Reminder data.</param> /// <param name="AReadWriteTransaction">Already instantiated DB Transaction.</param> /// <param name="Sender">Already instantiated SMTP sender.</param> /// <returns>True if the sending of the Reminder Email succeeded, otherwise false.</returns> private static bool SendReminderEmail(PPartnerReminderRow APartnerReminderDR, TDBTransaction AReadWriteTransaction, TSmtpSender Sender) { string Subject = ""; string Body = ""; string Destination = APartnerReminderDR.EmailAddress; string PartnerShortName; char LF = Convert.ToChar(10); // Retrieve ShortName of the Partner about whom the Reminder Email should be sent PartnerShortName = GetPartnerShortName(APartnerReminderDR.PartnerKey, AReadWriteTransaction); // Compose Email Subject Subject = String.Format("OpenPetra Reminder about {0}", PartnerShortName); /* * Compose Email Body */ Body = string.Format("Partner: {0} [{1:0000000000}]{2}", PartnerShortName, APartnerReminderDR.PartnerKey, LF); if (APartnerReminderDR.ContactId != 0) { Body += GetContactDetails(APartnerReminderDR.ContactId, AReadWriteTransaction); } Body += String.Format("Reason: {0}{1}", APartnerReminderDR.ReminderReason, LF); if (!APartnerReminderDR.IsEventDateNull()) { Body += String.Format("Event Date: {0}{1}", StringHelper.DateToLocalizedString(APartnerReminderDR.EventDate), LF); } Body += String.Format("Comment: {0}{1}", APartnerReminderDR.Comment, LF); Body += String.Format("{0}Next Reminder: {1}{2}", LF, StringHelper.DateToLocalizedString(APartnerReminderDR.NextReminderDate), LF); if (APartnerReminderDR.ReminderActive == false) { Body += String.Format("This Reminder has now been disabled.{0}", LF); } // Send Email (this picks up the SmtpHost AppSetting from the Server Config File) return(Sender.SendEmail(TAppSettingsManager.GetValue("NoReplyEmailAddress", "*****@*****.**"), "OpenPetra Server", Destination, Subject, Body)); }
public static bool MaintainChildReminders( String AComment, Int32 AReminderId, Int64 APartnerKey, DateTime AEventDate, DateTime AFirstReminderDate, out TVerificationResultCollection AVerificationResult) { SponsorshipTDS CurrentEdit; AVerificationResult = new TVerificationResultCollection(); if (APartnerKey == -1) { AVerificationResult.Add(new TVerificationResult("error", "no partner key", TResultSeverity.Resv_Critical)); return(false); } string dummy = ""; CurrentEdit = GetChildDetails(APartnerKey, -1, true, out dummy); PPartnerReminderRow EditReminderRow = null; // since we get a reminder id from the user (and i don't know how to request one of them) // we loop over all reminders, edit it if we found it, and if it's null we add a new one foreach (PPartnerReminderRow ReminderRow in CurrentEdit.PPartnerReminder.Rows) { if (ReminderRow.ReminderId == AReminderId) { EditReminderRow = ReminderRow; break; } } // edit if (EditReminderRow != null) { EditReminderRow.EventDate = AEventDate; EditReminderRow.FirstReminderDate = AFirstReminderDate; EditReminderRow.Comment = AComment; } else { PPartnerReminderRow NewReminderRow = CurrentEdit.PPartnerReminder.NewRowTyped(true); NewReminderRow.PartnerReminderId = -1; NewReminderRow.PartnerKey = APartnerKey; NewReminderRow.EventDate = AEventDate; NewReminderRow.FirstReminderDate = AFirstReminderDate; NewReminderRow.Comment = AComment; NewReminderRow.ReminderId = AReminderId; CurrentEdit.PPartnerReminder.Rows.Add(NewReminderRow); } try { SponsorshipTDSAccess.SubmitChanges(CurrentEdit); return(true); } catch (Exception e) { TLogging.Log(e.ToString()); AVerificationResult.Add(new TVerificationResult("error", e.Message, TResultSeverity.Resv_Critical)); return(false); } }
/// <summary> /// Sends a Reminder Email to a Partner. /// </summary> /// <param name="APartnerReminderDR">DataRow containing the Reminder data.</param> /// <param name="AReadWriteTransaction">Already instantiated DB Transaction.</param> /// <param name="Sender">Already instantiated SMTP sender.</param> /// <returns>True if the sending of the Reminder Email succeeded, otherwise false.</returns> private static bool SendReminderEmail(PPartnerReminderRow APartnerReminderDR, TDBTransaction AReadWriteTransaction, TSmtpSender Sender) { string Subject = ""; string Body = ""; string Destination = APartnerReminderDR.EmailAddress; string PartnerShortName; char LF = Convert.ToChar(10); // Retrieve ShortName of the Partner to which the Reminder Email should be sent PartnerShortName = GetPartnerShortName(APartnerReminderDR.PartnerKey); // Format Email Recipient Address as per email RFC's if (!Destination.Trim().StartsWith("<")) { Destination = "<" + Destination; } if (!Destination.Trim().EndsWith(">")) { Destination = Destination + ">"; } // Compose Email Subject Subject = String.Format("OpenPetra Reminder about {0}", PartnerShortName); /* * Compose Email Body */ Body = string.Format("Partner: {0} [{1:0000000000}]{2}", PartnerShortName, APartnerReminderDR.PartnerKey, LF); if (APartnerReminderDR.ContactId != 0) { Body += GetContactDetails(APartnerReminderDR.ContactId, AReadWriteTransaction); } Body += String.Format("Reason: {0}{1}", APartnerReminderDR.ReminderReason, LF); if (!APartnerReminderDR.IsEventDateNull()) { Body += String.Format("Event Date: {0}{1}", StringHelper.DateToLocalizedString(APartnerReminderDR.EventDate), LF); } Body += String.Format("Comment: {0}{1}", APartnerReminderDR.Comment, LF); Body += String.Format("{0}Next Reminder: {1}{2}", LF, StringHelper.DateToLocalizedString(APartnerReminderDR.NextReminderDate), LF); if (APartnerReminderDR.ReminderActive == false) { Body += String.Format("This Reminder has now been disabled.{0}", LF); } // Send Email (this picks up the SMTPServer AppSetting from the Server Config File) return Sender.SendEmail(Destination, "OpenPetra Server", Destination, Subject, Body); }
/// <summary> /// Sends a Reminder Email to a Partner. /// </summary> /// <param name="APartnerReminderDR">DataRow containing the Reminder data.</param> /// <param name="AReadWriteTransaction">Already instantiated DB Transaction.</param> /// <param name="Sender">Already instantiated SMTP sender.</param> /// <returns>True if the sending of the Reminder Email succeeded, otherwise false.</returns> private static bool SendReminderEmail(PPartnerReminderRow APartnerReminderDR, TDBTransaction AReadWriteTransaction, TSmtpSender Sender) { string Destination = APartnerReminderDR.EmailAddress; string PartnerShortName; string LanguageCode = "en"; string FirstName = ""; string LastName = ""; if ((Destination == String.Empty) && (APartnerReminderDR.UserId != String.Empty)) { // Get the email and language code of the user GetEmailOfUser(APartnerReminderDR.UserId, AReadWriteTransaction, out Destination, out LanguageCode, out FirstName, out LastName); } // Retrieve ShortName of the Partner about whom the Reminder Email should be sent PartnerShortName = GetPartnerName(APartnerReminderDR.PartnerKey, AReadWriteTransaction); string Domain = TAppSettingsManager.GetValue("Server.Url"); string EMailDomain = TAppSettingsManager.GetValue("Server.EmailDomain"); Dictionary <string, string> emailparameters = new Dictionary <string, string>(); emailparameters.Add("FirstName", FirstName); emailparameters.Add("LastName", LastName); emailparameters.Add("Domain", Domain); emailparameters.Add("partnername", PartnerShortName); emailparameters.Add("partnerkey", string.Format("{0:0000000000}", APartnerReminderDR.PartnerKey)); if (!APartnerReminderDR.IsContactIdNull() && APartnerReminderDR.ContactId != 0) { emailparameters.Add("ContactDetails", GetContactDetails(APartnerReminderDR.ContactId, AReadWriteTransaction)); } if (!APartnerReminderDR.IsReminderReasonNull()) { emailparameters.Add("Reason", APartnerReminderDR.ReminderReason); } if (!APartnerReminderDR.IsEventDateNull()) { emailparameters.Add("EventDate", String.Format("{0}", StringHelper.DateToLocalizedString(APartnerReminderDR.EventDate))); } emailparameters.Add("Comment", APartnerReminderDR.Comment); if (!APartnerReminderDR.IsNextReminderDateNull()) { emailparameters.Add("NextReminderDate", String.Format("{0}", StringHelper.DateToLocalizedString(APartnerReminderDR.NextReminderDate))); } if (APartnerReminderDR.ReminderActive == false) { emailparameters.Add("ReminderDisabled", "true"); } // Send Email (this picks up the SmtpHost AppSetting from the Server Config File) return(Sender.SendEmailFromTemplate( "no-reply@" + EMailDomain, "OpenPetra Admin", Destination, "reminder", LanguageCode, emailparameters)); }