Object: emails
Variables
Emails Object
.all
List of all available emails in the particular context.
Examples
CODE{% if session.user %}
{% for email in session.user.account.emails.all %}
{{ email.type }}: {{ email.email }} <br/>
{% endfor %}
{% else %}
not signed in, cannot list emails
{% endif %}
OUTPUTto: john@mysite.com
cc: orders@mysite.com
...
.by_type
List of all available emails of a particular type. There are 4 types of emails: to, cc, bcc and unknown
Examples
CODE{% if session.user %}
{% for email in session.user.account.emails.by_type.to %}
{{ email.type }}: {{ email.email }} <br/>
{% endfor %}
{% else %}
not signed in, cannot list 'to' email addresses
{% endif %}
OUTPUTto: john@mysite.com
...
Email List Object
.has
Evaluates to true if there is at least one email in the list.
Examples
CODE{% if session.user %}
{% if session.user.account.emails.by_type.to.has %}
user has 'to' email(s)<br/>
{% else %}
user does NOT have 'to' email<br/>
{% endif %}
{% else %}
not signed in, cannot access email list
{% endif %}
OUTPUTuser has 'to' email(s)
.size
Number of email addresses in the list.
Examples
CODE{% if session.user %}
user has {{ session.user.account.emails.by_type.to.size %} 'to' emails
{% else %}
not signed in, cannot access email list
{% endif %}
OUTPUTuser has 3 'to' emails
.first
Access to the first email in the list.
Examples
CODE{% if session.user %}
{% if session.user.account.emails.by_type.to.has %}
first 'to' email is {{ session.user.account.emails.by_type.to.first.email %}
{% else %}
user has no 'to' emails
{% endif %}
{% else %}
not signed in, cannot access email list
{% endif %}
OUTPUTfirst 'to' email is john@mysite.com
.all
All emails in the list.
Examples
CODE{% if session.user %}
{% for email in session.user.account.emails.by_type.to.all %}
'to' email: {{ email.email %}
{% endfor %}
{% else %}
not signed in, cannot access email list
{% endif %}
OUTPUT'to' email: john@mysite.com
'to' email: ian@mysite.com
...
.filter.<key>.<value>
Filter emails by a field. Filtering is usually done on metafield values, and it requires that the metafield name and value conform to reference name constraints, that is, contains only alpha-numeric, dashes and underscores. Multiple fiters can be applies after each other, narrowing down the result progressively.
To specify the filtering criteria, add two elements to the path, one for the key and the other for the value. For example, lets say there is an email with a metafield key of use, and value of invoices. To filter for an email matching this criteria, specify at the end of the access path something like ... .filter.use.invoices
. This will return an email list containing all emails having a metafield named use set to invoice.
Examples
CODE{% if session.user %}
use for invoices: {{ session.user.account.emails.by_type.to.filter.use.invoices.first.email %}
{% else %}
not signed in, cannot access email list
{% endif %}
OUTPUTuse for invoices: invoices@mysite.com
Email Object
.type
The type of the email. This is typically set to to, cc, bcc or unknown.
Examples
CODE{% if session.user %}
type of first email: {{ session.user.account.emails.all.first.type %}
{% endif %}
OUTPUTtype of first email: to
The email address.
Examples
CODE{% if session.user %}
first email: {{ session.user.account.emails.all.first.email %}
{% endif %}
OUTPUTfirst email: john@mysite.com