Loading...
 
Skip to main content

History: Email in Unified Index

Source of version: 19 (current)

Copy to clipboard
            ! Emails in Unified Index

Managing emails in Tiki is essential for users who want centralized access to their messages. With the addition of the report functionality for available emails, users can now view and manage emails from different folders and IMAP accounts.
The ((Unified Index Comparison|Unified Index)) in Tiki enhances the capability to manage emails effectively by integrating them into a centralized search. This documentation outlines how to utilize the new feature for reporting on available emails and provides examples for better email management.

!! Overview of the Feature

The aim of this functionality is to allow users to view the latest messages from specific folders or mailboxes and facilitates the easy movement or copying of these messages to another IMAP mailbox or tracker.

If no specific folder or account is set, the tool defaults to the current user's mailbox accessible via {CODE(wrap="0" theme="default")}tiki-webmail.php?page=message_list&list_path=combined_inbox{CODE}.

!! Use Cases

* Accessing emails from a low-volume mailbox that users may overlook.
* Tracking unread or flagged emails associated with specific tracker items.

!! Filtering Options

The filtering mechanism utilizes the syntax available in the ((PluginList)) plugin, providing flexible query capabilities. Here are some example queries:

* Show all unread or flagged emails in a tracker item in category 23.
* Show all emails less than 30 days old in tracker item 2672 and folder 'abc' of IMAP account 'XYZ'.

The integration with ((Cypht)) allows for saved searches to enhance usability.

!! Display Options

The display feature currently shows just the number of messages, with an option to click for access to detailed views.

!! DynamicList Usage

DynamicList can be used as a parent filter for sublist queries. It enables the extraction of emails based on specific relationships. The DynamicList should utilize the multivalue search index, allowing values to be stored as multivalues. For example, you can use filters to retrieve related objects by their IDs with the following syntax:
{CODE(caption="Tiki syntax" wrap="1" theme="default")}{filter field="object_id" content="parent.relationFieldName|object_ids"}{CODE}
This converts the IDs of related objects into an array, facilitating more precise searching within the search index. For relation fields, you can also use:
{CODE(caption="Tiki syntax" theme="default")}{filter field="relations" multivalue="tiki.file.attach.invert:trackeritem.object_id|multivalue"}{CODE}
This allows for searching and matching multivalue items stored in the ((Search and List from Unified Index|index)).

!! Example Queries
Here are some examples of Tiki syntax that can be used to leverage this new functionality:
* __1. Emails attached to a tracker item via a relation field:__
{CODE(caption="Tiki syntax" theme="default")}!!! Emails attached to $$widget1 [item784]$$ via the relation field
{LIST()}
{filter type="file"}
{filter field="email_date" content="NOT "}
{filter field="relations" multivalue="tiki.file.attach.invert:trackeritem:784"}
{LIST}{CODE}
* __2. Unread emails attached to a tracker item:__
{CODE(caption="Tiki syntax" theme="default")}!!! Unread emails attached to $$widget1 [item784]$$ via the relation field
{LIST()}
{filter type="file"}
{filter field="email_date" content="NOT "}
{filter field="email_flags" multivalue="NOT Seen"}
{filter field="relations" multivalue="tiki.file.attach.invert:trackeritem:784"}
{LIST}{CODE}
* __3. Emails from the last 30 days from a specific IMAP folder in Cypht:__
{CODE(caption="Tiki syntax" theme="default")} !!! Emails from the last 30 days from a specific IMAP folder in Cypht {LIST()}
{filter cypht="example@example.org>INBOX, example@example.org>Sent"}
{filter range="email_date" to="now" gap="30 days"}
{sort mode="email_date_desc"}
{OUTPUT(template=table)}
  {column label="Subject" field="subject" mode="raw"}
  {column label="From" field="from" mode="raw"}
  {column label="Date" field="date"}
{OUTPUT}
{LIST}
{CODE}

* __4. Emails in the past 1200 days attached to [item784] via relations field:__

{CODE(caption="Tiki syntax" theme="default")}!!! Emails in the past 1200 days attached to [item784] via relations field
{LIST()}
{filter type="file"}
{filter range="email_date" to="now" gap="1200 days"}
{filter field="relations" multivalue="tiki.file.attach.invert:trackeritem:784"}
{sort mode="email_date_desc"}
{OUTPUT(template=table)}
  {column label="Subject" field="subject" mode="raw"}
  {column label="From" field="from" mode="raw"}
  {column label="Date" field="date"}
{OUTPUT}
  {FORMAT(name="subject")}{display name="email_subject" format="objectlink"}{FORMAT}
  {FORMAT(name="from")}{display name="email_from"}{FORMAT}
  {FORMAT(name="date")}{display name="email_date" format="datetime"}{FORMAT}
{LIST}{CODE}

* __5. Emails attached to tracker 4 via sublist:__
{CODE(caption="Tiki syntax" theme="default")}!!! Emails attached to tracker 4 via sublist
{LIST()}
{filter type="trackeritem"}
{filter field="tracker_id" exact="4"}
{SUBLIST(name="files" multiple="1" required="1")}
{filter field="object_type" exact="file"}
{filter field="email_date" content="NOT "}
{filter field="relations" multivalue="tiki.file.attach.invert:trackeritem:$parent.object_id|multivalue$"}
{SUBLIST}
{OUTPUT(tplwiki="Email Report tpl")}
{OUTPUT}
{LIST}{CODE}

* __6. Emails attached to items for category A via sublist:__
{CODE(caption="Tiki syntax" theme="default")}!!! Emails attached to items for category A via sublist
{LIST()}
{filter type="trackeritem"}
{filter categories="30"}
{SUBLIST(name="files" multiple="1" required="1")}
{filter field="object_type" exact="file"}
{filter field="email_date" content="NOT "}
{filter field="relations" multivalue="tiki.file.attach.invert:trackeritem:$parent.object_id|multivalue$"}
{SUBLIST}
{OUTPUT(tplwiki="Email Report tpl")}
{OUTPUT}
{LIST}{CODE}

 For example, your custom template in the "Email Report tpl" page could look like this:
{CODE(caption="Using a Wiki page as smarty template" theme="default")}
{if $emails|@count > 0}
    <h2>Email Report</h2>
    <div>
        {foreach from=$emails item=email}
            <div>
                <h3>{$email.subject}</h3>
                <p><strong>From:</strong> {$email.from}</p>
                <p><strong>Date:</strong> {$email.date|date_format:"%Y-%m-%d %H:%M:%S"}</p>
                <p><strong>Body:</strong> {$email.body}</p>
            </div>
            <hr>
        {/foreach}
    </div>
{else}
    <p>No emails found.</p>
{/if}
{CODE}

* __7. Emails from the last 30 days from a specific IMAP folder(s) in Cypht:__
{CODE(caption="Tiki syntax" theme="default")}!!! Emails from the last 30 days from a specific IMAP folder(s) in Cypht
{LIST()}
{filter cypht="example@example.org>INBOX, example@example.org>Sent"}
{filter range="email_date" to="now" gap="30 days"}
{filter field="email_flags" multivalue="Seen"}
{sort mode="email_date_desc"}
{OUTPUT(template=table)}
  {column label="Subject" field="subject" mode="raw"}
  {column label="From" field="from" mode="raw"}
  {column label="Date" field="date"}
{OUTPUT}
  {FORMAT(name="subject")}{display name="email_subject" format="objectlink"}{FORMAT}
  {FORMAT(name="from")}{display name="email_from"}{FORMAT}
  {FORMAT(name="date")}{display name="email_date" format="datetime"}{FORMAT}
{LIST}{CODE}

* __8. Emails from the last 30 days from a special folder in Cypht:__
{CODE(caption="Tiki syntax" theme="default")}!!! Emails from the last 30 days from a special folder in Cypht
{LIST()}
{filter cypht="Everything"}
{filter range="email_date" to="now" gap="30 days"}
{sort mode="email_date_desc"}
{OUTPUT(template=table)}
  {column label="Subject" field="subject" mode="raw"}
  {column label="From" field="from" mode="raw"}
  {column label="Date" field="date"}
{OUTPUT}
  {FORMAT(name="subject")}{display name="email_subject" format="objectlink"}{FORMAT}
  {FORMAT(name="from")}{display name="email_from"}{FORMAT}
  {FORMAT(name="date")}{display name="email_date" format="datetime"}{FORMAT}
{LIST}{CODE}

A special thanks to Victor Emanouilov for the code examples provided.

With the addition of the report functionality for available emails, Tiki users can now manage their emails more efficiently and organized. This not only enhances the user experience but also facilitates the integration of emails into existing workflows.