Menu

class: personalization

[103:7] extends: object

This class is provided to allow personalization to each sender of an email. The class name is long but it matches the one used by SendGrid API.

Members

  • to

    List of to email address.

  • from

    Optional from email address.

  • cc

    Optional list of carbon copy email address.

  • bcc

    Optional list of blind carbon copy email address.

  • headers

    Optional map of email headers.

  • subject

    The email subject.

  • sendAt

    This is an int with the milliseconds since epoch with the date at which to send the email.

Methods

  • personalization (list ToEmailAddresses)

    Craetes a new personalization object with the provided list of to email addresses.

    • @p ToEmailAddresses is a list of strings with the to email addresses.
    • @r this object
  • setTo (list ToEmailAddresses)

    Sets the list of to email addersses.

    • @p ToEmailAddresses is a list of strings with the to email addresses.
    • @r this object

class: attachment

[172:7] extends: object

This class is used to provide an attachment to the sendgrid object to send in an email.

Members

  • fileName

    This is the string with the file name of the attachment.

  • content

    The content field will contain a string with the data. It will be either a plain text string, or a Base64 encoded binary file.

  • type

    The mime type of the attachment. ('text/plain', 'text/html', ...)

  • disposition

    A string with the email disposition. (default null)

  • contentId

    If disposition is set to 'inline' then this can be set and used to display images within an email body. (default null)

Methods

  • attachment (string FileName, Content)

    Default constructor sets the provided file name and content. The content can either be a string or a Buffer object. One thing to note, if this is a binary file, make sure to read it with file.readBinary() instead of file.read() because file.readBinary() will return a Buffer object with the binary data and attachment will deal with that file properly.

    • @p FileName is a string with the file name to set.
    • @p Content is either a string or a Buffer object with the content.
    • @r this object
  • setFile (string FileName, string Content)

    Sets a plain text file attachment with the provided file name and content.

    • @p FileName is a string with the attachent file name.
    • @p Content is a string with the file contents.
    • @r this object
  • setBinaryFile (string FileName, object Buff)

    Sets a binary file attachment with the provided file name and content.

    • @p FileName is a string with the attachent file name.
    • @p Buffer is a Buffer object with the file contents.
    • @r this object

class: sendgrid

[29:14] (extern: com.lehman.aussomserver.connectors.AussomSendGrid) extends: object

The sendgrid class provides email sending functionality provided by Twilio SendGrid. It supports sending a single simple email to advanced and customized options. If you can every get through the SendGrid/Twilio account creation process (good luck), here's how you get an API key. Under Settings -> API Keys -> Create API Key. Give it a meaningful name and create the Key. Copy it to a safe place, you will need it to provide in the constructor.

Methods

  • sendgrid (string ApiKey)

    Create a new sendgrid object with the provided API key.

    • @p ApiKey is a string with the sendgrid API key to use.
    • @r this object
  • newSendGrid (string ApiKey)

  • from (string FromEmail)

    Set the from email address.

    • @p FromEmail is a string with the from email address.
    • @r this object
  • to (string ToEmail)

    Sets the to email addess with the provided email address string. Note that this function will clear any existing

  • subject (string Subject)

    Sets the provided subject string.

    • @p Subject is a string with the subject to set.
    • @r this object
  • content (string Content, string ContentType = "text/plain")

    Sets the provided content string and the optional content type string.

    • @p Content is a string with the content to set.
    • @p ContentType is an optional string with the content type to set. (default: text/plain)
    • @r this object
  • send ()

    Sends the email(s) and returns a map with the results. The result map will have statusCode, body, headers which is a map of string - string with the headers.

    • @r A map with the response.
  • addPersonalization (object Personalization)

    Adds the provided personalization object. See the personalization object for details.

    • @p Personalization is the personalization object to add.
    • @r this object
  • addAttachment (object Attachment)

    Adds the provided attachment object. See the attachment object for details.

    • @p Attachment is the attachment object to add.
    • @r this object