action.skip

Controlling Email Options

← Setting Up Invoice Distribution

The usual way to distribute finalized invoices, dunning reminders or account statements is email. To this end, JustOn Billing & Invoice Management relies on the email service provided by the Salesforce Platform.

Info

For an invoice or statement to be considered in the email distribution, the checkbox Email Invoice or, respectively, Email Statement must be selected.

For information about what is contained in the email, like subject, text body, etc., see Email Contents.

This article summarizes important aspects and possible questions that may arise in this context.

Email Status

email
Sending emails from JustOn

JustOn stores the email distribution status in the field Email Status on the invoice or statement. There are the following statuses:

Email Status Description
Unsent The default status: the email has not been sent yet.
Queued The email is put in the queue for being sent by the corresponding job.
Is set either after a user has clicked Send.
Sent The email has been successfully sent by the email job.
Error The email has not been sent because of an error. The error message is written to the field Email Error.
The email job tries to resend the invoice email on its next run.

Email Auto Send

Your organization's business may require to send invoice or statement emails automatically upon finalization when certain conditions become true.

To support this scenario, you add the checkbox AutoSend to the Invoice or Statement object. You can then apply custom logic to have this checkbox set selectively on specific records or globally on all produced records using a formula, the ON field mechanism or a Salesforce Flow. Remember that for an invoice or statement to be considered in the email distribution, the checkbox Email Invoice or, respectively, Email Statement must be selected.

Note

For the auto send feature to work, the custom setting Auto Queue Emails After Finalization must not be selected.

  1. Navigate to the fields list of the Invoice or Statement object.
  2. Create the following new field.

    API Name Data Type Description
    AutoSend Formula (Checkbox)
    Checkbox
    When selected, JustOn Billing & Invoice Management will automatically send the emails on invoice or statement finalization.

    For help about creating fields, see Managing Object Fields.

Info

If mandatory file attachments are missing (Invoice PDF or E-Invoice, if defined accordingly), JustOn Billing & Invoice Management will write an error message to the invoice field Email Error and exclude the corresponding email from sending.

Email Job

Unless specifically configured (see Email Auto Send), emails are not sent immediately on invoice or statement finalization. Instead, JustOn queues the emails and sends them at 03:00 every day by default. To this end, it provides the Apex class EmailJobChain, which is set up accordingly as a scheduled job.

Your business may, however, require another email interval. In this case, you change the email job schedule:

  1. Open the Scheduled Jobs page.

    Use the following URL https://login.salesforce.com/apex/ONB2__JobsSetup, or, if you are already logged in, append apex/ONB2__JobsSetup to your org's domain name.

    You can access the Scheduled Jobs page via the JustOn configuration app ( > JustOn Configuration > Jobs Setup).

  2. From the Apex Job picklist, select Email Job.

    The Job Name field is automatically set to EmailJobChain.

    alt text
    Scheduling email job

  3. From the Start Time picklist, select the preferred execution time.

  4. Optionally, edit the displayed cron expression to adjust the execution time.
  5. Click Schedule.

    This sets up the email distribution to be executed at the specified time.

Info

Clicking Run immediately you can execute the batch chain instantly.

Email Attachments

Generally, any type of files that is possibly to be attached to invoice emails must be defined as a content version type – that is, they must be specified in the Type field of the Content Version object. All files produced by JustOn Billing & Invoice Management hold a proper type, like Invoice PDF or E-Invoice. Your business may require additional documents to be attached to invoices. To this end, you define a custom content version type that can then be included in the invoice distribution.

In addition, you define the files to be preselected as attachments to invoice emails. To do so, you specify their content version type in the Invoice field Email File Types. This field can be populated on invoice creation from other records like this:

ON_EmailFileTypes from the account or invoice source record
Email File Types from the template
     ↳ Email File Types from the business entity

If Email File Types remains empty, JustOn Billing & Invoice Management assumes Invoice PDF as mandatory, making it preselected as email attachment.

Invoice attachment specifics

When configuring the files to be attached to invoice emails, be aware of the following specifics:

  • If Email File Types is empty, JustOn Billing & Invoice Management assumes Invoice PDF as mandatory, making it preselected as email attachment.
  • If you want other files to be preselected in addition to Invoice PDF, set both Invoice PDF and the relevant additional content version types in Email File Types like, for example, Invoice PDF, E-Invoice.

    Adding only additional types, omitting Invoice PDF, makes the invoice PDF a non-mandatory, optional attachment.

  • Only Invoice PDF and E-Invoice can be mandatory file types (if explicitly specified in Email File Types like Invoice PDF, E-Invoice). So any possible errors on missing mandatory files may relate only to Invoice PDF and E-Invoice.

  • If Email File Types contains the string ALL, all other files with or without a defined content version type from the invoice will be preselected as email attachment.
  • If Email File Types contains the string BLANK, all other available files where the content version type is empty will be preselected as email attachment.
  • The template field Attach Files To Outgoing Email must still be selected for any files to be attached.
  • Defining attachments affects the email distribution as follows:

    • When sending single invoices, the corresponding files are preselected as attachments. Users can still deselect them or select additional attachments and proceed to sending the email.
    • When sending multiple invoices from a list view or when having emails sent automatically, the corresponding files are selected as attachments. If one of the mandatory attachments is missing (Invoice PDF or E-Invoice, if defined accordingly), JustOn Billing & Invoice Management will write an error message to the invoice field Email Error and exclude the corresponding email from sending.

To define a custom content version type:

  1. Click to enter Setup, then navigate to the object management settings of the Content Version object.
  2. Click Fields & Relationships.
  3. Click the name of the Type field.
  4. In the Values section, click New.

    Add the required content version types, each in a new line.

  5. Click Save.

    For help about editing picklists, see Modifying Picklist Values.

To define the preselected invoice email attachments from the invoice sources:

  1. Click to enter Setup, then navigate to the object management settings of the Account object or the source object.
  2. Click Fields & Relationships.
  3. Create the following new field.

    Field Label API Name Data Type
    Email File Types ON_EmailFileTypes Text(255)
    Formula (Text)

    Your business may require to automatically set the intended file types depending on certain conditions. In this case, create a formula field with the return type Text, where the formula represents the intended logic. Otherwise, create a simple text field and let users specify the value manually.

To define the preselected invoice email attachments from the template or the business entity:

  1. Open the relevant template or business entity.
  2. Click Edit.
  3. In the Email File Types field, specify the content version types as necessary.
  4. Click Save.

Email Sender Address

When sending emails, Salesforce usually puts the current user's email address as the sender address. Your business may, however, require to use a generic or role-based email from address, like, for example, billing@company.com, irrespective of the user who actually sends the messages.

Enabling this scenario comprises two tasks:

  • Defining one or more organization-wide email addresses.
  • Specifying the organization-wide address in the Email Sender field on the template (or the business entity).

To define an organization-wide email address:

  1. Click to enter Setup, then open Organization-Wide Addresses.

    In Salesforce Lightning, navigate to Email > Organization-Wide Addresses.

    In Salesforce Classic, navigate to Email Administration > Organization-Wide Addresses.

  2. Click Add.

  3. Specify the display name and the email address in the corresponding fields.
  4. Specify whether to use this address for all or selected profiles.

    Select the profiles as necessary.

  5. Click Save.

    This associates the organization-wide email address to the selected user profiles, making it available for each user in the profile as the sender address. Note that the users will share the same display name and email address.

To specify the organization-wide address on the invoice template:

  1. Open the template to be edited.
  2. In the Email Text section, click next to the Email Sender field and specify the organization-wide email address.
  3. Click Save.

    This puts the specified address as the email from address for all invoice emails that are based on the current template.

Info

You can also define an organization-wide email address in the Email Sender field of the business entity. Be aware, however, that the address set on the template takes precedence over the address set on the business entity.

Email Tracking

To help tracking the invoice distribution, JustOn creates a history task for sent invoice emails. The task is assigned to the contact set in Email Contact on the invoice (see Address Data Flow). The generated task records are displayed in the Activities list on the related invoice.

Note

Due to security-related modifications introduced with JustOn 2.74, you must explicitly allow Read and Edit access to the Type field of the Task object, as described in Enabling Access for New Users.

invoice_history_task
Displaying tasks on invoices

Info

Note that record types for Task records are always project specific. Therefore, JustOn cannot programmatically support your record types. For details about working with record types, see Tailor Business Processes to Different Users in the Salesforce Help.

JustOn saves the past activity by default when emailing invoices. The Activities list, however, is not visible on the invoice page by default. To enable the Activities display:

  1. Open an invoice.
  2. Click to open the Setup menu, then select Edit Page.
  3. Drag the Activities component to the intended region of the page.
  4. Click Save.

    For help about modifying pages, see Managing Pages.

Note

Make sure that the default activities view is set to Activity Timeline (see Set the Default Activities View in the Salesforce Help). Otherwise, the Activities list will not be accessible via the Lightning record page.

Disabling Email Tracking

If you do not want these email tracking activities to be created, you can disable this functionality. To do so:

  1. Click to enter Setup, then open Custom Settings.

    In Salesforce Lightning, navigate to Custom Code > Custom Settings.

    In Salesforce Classic, navigate to Develop > Custom Settings.

  2. Click Manage in the row of Global Settings.

  3. Click Edit in the Default row.
  4. Deselect the checkbox Track E-Mail.
  5. Click Save.

Email Limit

On the Salesforce platform, you can send mass email (using the API or Apex) to a maximum of 5000 external email addresses per day per org. Under certain conditions, Salesforce Support may temporarily raise your org's mass email limit. For details, see Mass Email Limitations in the Salesforce Help.

Depending on your business, your org may permanently need to send more emails per day. To support this, JustOn can integrate with the Amazon Simple Email Service (SES) to send out invoices, dunning reminders and account statements.

Info

The Amazon SES integration is an enterprise extension feature and subject to additional charges. For details, contact JustOn Support.

For details about enabling the Amazon SES integration, see Enabling Amazon Simple Email Service.

Email Security Compliance

Salesforce uses the Sender Policy Framework (SPF), an email authentication method designed to detect forged sender addresses, aiming at reducing spam and fraud. Email providers use SPF to verify the authenticity of email senders based on the sender address of the email envelope (which is different from the email header's From: address displayed to users).

Enabling email security compliance sets the envelope sender address to bnc.salesforce.com. This is an authorized domain, so emails sent from Salesforce will pass SPF checks. The header From: address remains set to the configured sender's email address. For details, see Sender Policy Framework (SPF) in the Salesforce Help.

Some recipients may use the (less common) Sender ID email authentication protocol. As an option, Salesforce can, additionally, enable Sender ID compliance. Doing so sets the envelope sender address to noreply@salesforce.com. Consequently, a number of email clients append a phrase like Sent on behalf of to the header's From: field if the sending domain (in the envelope) differs from the domain of the configured sender's email address. Users then may see, for example noreply@salesforce.com on behalf of .... For detals on removing noreply@salesforce.com or Sent on behalf of from outgoing email, see How to remove noreply@salesforce.com from sender address?.

Info

Emails sent from Salesforce may be considered non-personal bulk email, and therefore get caught in spam filters. To prevent this from happening, you can use Salesforce's email relay functionality, which routes outgoing emails through your company's mail server using your real email address.

Related information:

Send Email from Salesforce in the Salesforce Help
Checking Email Deliverability
Preventing Emails Being Filtered as Spam
PDF and Email FAQ