/// <summary> /// Creates an empty mail merge message. /// </summary> public MailMergeMessage() { Config.IgnoreIllegalRecipientAddresses = true; Config.Priority = MessagePriority.Normal; Headers = new HeaderList(); Subject = string.Empty; SmartFormatter = new MailSmartFormatter(this); // Smart.Format("{Name:choose(null|):N/A|empty|{Name}}", variable), where abc.Name NULL, string.Emtpy or a string MailMergeAddresses = new MailMergeAddressCollection(this); }
/// <summary> /// Creates an empty mail merge message. /// </summary> public MailMergeMessage() { Config.IgnoreIllegalRecipientAddresses = true; Config.Priority = MessagePriority.Normal; Headers = new HeaderList(); Subject = string.Empty; SmartFormatter = new MailSmartFormatter(this); // Smart.Format("{Name:choose(null|):N/A|empty|{Name}}", variable), where abc.Name NULL, string.Emtpy or a string SmartFormatter.OnFormattingFailure += (sender, args) => { _badVariableNames.Add(args.Placeholder); }; MailMergeAddresses = new MailMergeAddressCollection(this); }
/// <summary> /// Creates an empty mail merge message. /// </summary> public MailMergeMessage() { Config.IgnoreIllegalRecipientAddresses = true; Config.Priority = MessagePriority.Normal; if (Config.SmartFormatterConfig == null) { Config.SmartFormatterConfig = new SmartFormatterConfig(); } SmartFormatter = new MailSmartFormatter(Config.SmartFormatterConfig); Config.SmartFormatterConfig.OnConfigChanged += SmartFormatter.SetConfig; // Smart.Format("{Name:choose(null|):N/A|empty|{Name}}", variable), where abc.Name NULL, string.Emtpy or a string SmartFormatter.OnFormattingFailure += (sender, args) => { _badVariableNames.Add(args.Placeholder); }; _mailMergeAddresses = new MailMergeAddressCollection(this); }
/// <summary> /// Gets the MailAddress representation of the MailMergeAddress. /// </summary> /// <returns>Returns a MailAddress ready to be used for a MailAddress, or Null if no address part exists.</returns> /// <exception cref="NullReferenceException">Throws a NullReferenceException if TextVariableManager is null.</exception> /// <exception cref="FormatException">Throws a FormatException if the computed MailAddress is not valid.</exception> internal MailboxAddress GetMailAddress(MailSmartFormatter formatter, object dataItem) { string address = formatter.Format(Address, dataItem); string displayName = formatter.Format(DisplayName, dataItem); if (string.IsNullOrEmpty(displayName)) { displayName = null; } // Exclude invalid address from further process if (!EmailValidator.Validate(address, false, true)) { return(null); } return(displayName != null ? new MailboxAddress(DisplayNameCharacterEncoding, displayName, address) : new MailboxAddress(DisplayNameCharacterEncoding, address, address)); }