Mail Queue

The Mail class provides the ability to configure simple mail templates to provide the text for email notifications. It also allows delayed sending of messages from Rules Extension code. This means that users can receive their notification messages after synchronization completes and changes have been pushed out to connected systems instead of earlier in the process when there may be hours left before the changes are live.

Mail Class

The Mail class contains a GetTemplate method that looks up an email template by name. It also contains a Queue method that adds a new message to the mail queue table which can be sent later when synchronization has completed. In order for Mail templates and the mail queue table to function the Mail Config section must be configured.

  • MailTemplate GetTemplate(string name) – This method takes a name and looks up the mail template from the App.config file.
  • void Queue(recipients, subject, message, params object[] args) – This method adds a new message to the queue.
    • recipients – semicolon separated list of email address (gets passed to System.Net.Mail.MailMessage)
    • subject – string subject for message
    • message – message format string
    • args – the args parameter is combined with the message.

When a mail message is queued, the subject and message parameters are formatted with values form the args array.

If an object in the args list is a Hologram, then all subject or message substrings in the form [attributeName] will be replaced with the attribute’s original value as represented in the Hologram.

If an object in the args list is a ChangeSet, then subject or message substrings in the form [attributeName.field] (where field is OldValue, NewValue, or Direction) will be replaced.

All other objects in the args list will be treated as positional arguments to String.Format.

MailTemplate class

The MailTemplate class is deserialized from the App.config file by the Config system. It has public string properties for Subject and Message, and may be looked up by its public Name property.

Mail Configuration

The <Mail> section should have a <connectionString> element that provides the database connection to store the mail queue.

The <table> element names the table to store mail queue data in. This table will be created automatically, provided the FIM Rules Extension executes with sufficient privileges.

The MailTemplates section may have as many mail templates as desired. A mail template is defined using the <template> element with attributes for name, and subject. The content of the element is the message and may be multiline.

Example Mail Configuration

  <connectionString>Server=localhost;Database=FIMSupport;Integrated Security=True</connectionString>
    <template name="NewUser" subject="New User Created">
      You have been identified as the helpdesk owner for a new user
      who has been created in Active Directory.

      EmployeeID: [employeeID]
      Username: [sAMAccountName.NewValue]
      Initial Pwd: {0}

      Please contact this user and help them start using their account.

      (Automated identity management message)

Copyright © SoftwareIDM