         messageId = form.msgId ? form.messageId
 
         if not messageId or not (message = GmailApp.getMessageById messageId)
-          Logger.log "Given message ID '%s' is not valid", messageId
+          MailButler.log "Given message ID '#{messageId}' is not valid"
           throw new Error ErrorCodes.INVALID_MESSAGE_ID,
             email:      encodeURIComponent user
             messageId:  messageId
 
         unless form.when
-          Logger.log 'No scheduling time given'
+          MailButler.log 'No scheduling time given'
           throw new Error ErrorCodes.NO_SCHEDULE_TIME
 
         unless (w = MailButler.parseTime form.when, now)
-          Logger.log "Given scheduling time '%s' is not valid", form.when
+          MailButler.log "Given scheduling time '#{form.when}' is not valid"
           throw new Error ErrorCodes.INVALID_SCHEDULE_TIME, {time: form.when}
 
         props =

  constructor: (@prefix) ->


  @logException: (message) ->
    SpreadsheetApp.openById(@SPREADSHEET_KEY).appendRow [
                                                        new Date().toUTCString()
                                                        @getName()
                                                        @getEmail()
                                                        message?.toString()
                                                        ]
    return




  @getScheduledMails: ->
    user = @getEmail()
    MailButler.log "Get scheduled mails for #{user}"
    result = @DB.getMails user, null, null, false
    result.next() while result.hasNext()

  @processButlerMails: (d) ->
    MailButler.log "Checking for scheduled mails on #{d.toUTCString()}"

    user = @getEmail()
    time = d.getTime()
    MailButler.log "With user '#{user}', version '#{@VERSION}' and time #{time}"
    result = @DB.getMails user, @VERSION, time, false

    if (s = result.getSize()) > 0
      # yep there are some
      MailButler.log "... found #{s} candidates"

      while result.hasNext()
        @processButlerMail result.next(), time

    else
      # No scheduled messages available
      MailButler.log "... none found."
    return

  @processButlerMail: (props, time) ->
    MailButler.log "Process mail with props: #{JSON.stringify(props)}"

    messageId = props.messageId
    message = GmailApp.getMessageById messageId if messageId

    unless message
      # Message does not exist or is invalid
      MailButler.log "Message with ID '#{messageId}' does not exist or is invalid"

      # Set the status
      props.status = ProcessingStatus.NOT_FOUND
