# Developer Tips

## Implementation

The Squirrel server add-in is written entirely in Java which includes the open source Java framework [JAddin](https://jaddin.abdata.ch) (for HCL Domino server add-in) and the freeware [SOFA](https://sofa.k43.ch) (for OAuth 2.0 authentication). The HCL Notes front-end is a pure HCL Notes application distributed in a single NTF database template..

## Email Document

The original body of the Internet mail will be saved in the Notes document as a Notes MIME type item. The original MIME headers are preserved and saved in the Notes document.

## Additional Notes Items

Before forwarding messages to HCL Domino, the following items are added to preserve the original fields from the Internet email message. These items may be used to process messages in the users in-box with agents or to create new views or additional columns.

| Notes Item          | Item Type | Description                                                                   |
| ------------------- | --------- | ----------------------------------------------------------------------------- |
| $SquirrelVersion    | String    | Squirrel program version (e.g. 1.0.0)                                         |
| $SquirrelRecipient  | String    | Original IMAP/POP3 recipient name (e.g. <jsmith@gmail.com>)                   |
| $SquirrelPostedDate | DateTime  | Date and time of the Squirrel message processing                              |
| $SquirrelHostname   | String    | Internet host name of the mail server (e.g. imap.gmail.com)                   |
| $SquirrelProtocol   | String    | Protocol used to retrieve the email messages (IMAPS, IMAP, POP3S or POP3)     |
| $SquirrelFolder     | String    | Folder name of the original email messages (e.g. *INBOX*, *Office\ToDo*, etc) |

## Notes Delivered Time / Posted Time

Squirrel will set the Notes item *PostedDate* to the original date and time of the message. The Notes item *DeliveredDate* is set by the Domino router to the date and time when the message was actually processed by the router task (stored in the users mail database). If you want the user to see the original date and time of the message, you must change the formula of the Inbox folder column to show the *PostedDate* instead of the *DeliveredDate*.

## Folder Processing

The Notes item *$SquirrelFolder* contains the folder name of the original message. POP3 messages always return the name of the inbox where IMAP messages will contain the full name of the folder. This item may be used in a Notes pre-delivery agent (*Before new mail arrives*) to add the message to the corresponding folder, e.g.

```
Sub Initialize
    Dim Session As New NotesSession
    Dim Document As NotesDocument
    Dim FolderName As String

    Set Document = Session.DocumentContext
    FolderName = Document.getItemValue("$SquirrelFolder")(0)

    ' Move the message to the original folder
    If ((FolderName <> "") And (UCase(FolderName) <> "INBOX")) Then
        Call Document.PutInFolder(FolderName)
        Call Document.RemoveFromFolder("($Inbox)")
    End If
End Sub
```
