SalesTrip includes functionality whereby a user can email an attachment of a receipt to Salesforce via Salesforce Email Service functionality. The attachment will then be scanned and a new expense created from the details of that receipt. Here are detailed instructions on how to set the email service up:
- Go to Salesforce Setup
- Go to "Custom Code" → "Email Services"
- Create a new Email Service
- Give the service a meaningful name
- Select salestrip.ExpenseEmailOcrService as the Apex Class
- Ensure you accept binary attachments. SalesTrip can process png, tiff, jpg and pdf at this time, and only processes the first attachment it finds.
- Configure other fields per your business requirements. SalesTrip recommend you restrict senders to your domain, and email security if you can (speak to your email/network administrator).
- Mark the service Active if you are ready to use it
- Click "Save and New Email Address"
- Give the email address a meaningful name.
- Set the address as Active if you are ready to use it
- Set the context user to be a system administrator. This person will own expenses where the sender's email address could not be matched to a Salesforce user.
- Ensure you restrict the addresses emails are accepted from appropriately
- Click Save. Salesforce will generate a new unmemorable email address for your users to email their receipts to:
- On Developer console → access Debug → Open Execute Anonymous Window → add the script below →click Execute:
Datetime scheduleTime = System.now();
for(Integer i = 1; i <= 12; i++) {
System.schedule('SalesTrip Polling ' + i, '0 ' + scheduleTime.minute() + ' * * * ?', new salestrip.OcrPollingSchedule());
scheduleTime=scheduleTime.addMinutes(5);
}
- (optional) Contact your email administrator to create a more memorable address on your domain (e.g. receipts@mycompany.com). This email address should be configured to relay emails to the Email Address of the Email Service you configured above. Unfortunately we cannot provide detailed instructions as email servers vary.
If the sender’s email address corresponds to an email address with your Salesforce environment then that person will be the owner of the generated expense record. However, if a match on email address cannot be achieved than the owner is set as the user that the email service runs as. It is advised that expenses “assigned” to this user be periodically reviewed, in particular:
- Record Owner
- Trip
- Business Reason