3. Email Invoice

Prepare the IMan dataset for Emailing

In this step we will add a number of fields to the IMan dataset so they can be used to dynamically populate contents of the email to be sent to a customer.

Setup the Customer Lookup

We will create a lookup to retrieve some key customer data from the Customer record.

  1. Save the integration and go to the Setup area, then click Lookups, and double click the top row to create a new Lookup.

  1. Enter the values as per the following:

  1. Lookup ID
    • SAGE300INV
  2. Description
    • Sage300 Customer by Invoice Lookup
  3. Lookup from IMan DB
    • Unchecked
  4. Select Clause
    • NAMECUST, NAMECTAC, AMTBALDUET, EMAIL2
  5. From Clause
    • ARCUS inner join OEINVH on CUSTOMER = IDCUST
  6. Where Clause
    • INVNUMBER = '%1'
  1. Press the Green tick to Save.

Setup the Map Transform

  1. Return to the Designer, load the integration, click the Transform setup tab and add a Map transform to the O/E Invoice connector created in the last section.

  1. Click the Field Mapping tab and add three new fields as per the following:
  1. Name
    • ContactName
  2. Field Type
    • Text
  3. Enable Script Evaluation
    • Checked
  4. Formula
    • Dim Result
      Result = Lookup("SAGE300INV", "NAMECTAC", %INVOICE, True)
      If Result = "" Then
      Result = Lookup("SAGE300INV", "NAMECUST", %INVOICE, True)
      End If
      Result
  1. Name
    • Balance
  2. Field Type
    • Text
  3. Enable Script Evaluation
    • Checked
  4. Formula
    • Lookup("SAGE300INV", "AMTBALDUET", %INVOICE, True)
  1. Name
    • Email
  2. Field Type
    • Text
  3. Enable Script Evaluation
    • Checked
  4. Formula
    • Lookup("SAGE300INV", "EMAIL2", %INVOICE, True)
  1. Press Refresh.

  1. Press Apply to save then close.

Using the Email Task

In this step you will learn how to setup the email task.

  1. Click on the Tasks group on the left hand of the designer and connect an Email task to the end of the Map transform.

  1. Expand the Email Addresses group and enter the following:
  1. From Address
    • Replace with your email address.
  2. To Address
    • Typically you would dynamically populate this with a value from your dataset. That is, %INVOICE.Email
    • Enter your address.

  1. Collapse the Email Addresses group.
  2. Enter / select the following values:

  1. Send Individual Emails
    • With this check every address in the To address will send a separate email.
    • For training: checked
  2. Generate Separate Emails Per
    • This will generate an email for each OEINVPRINT record i.e. for each invoice.
    • For training, enter: OEINVPRINT
  3. Subject
    • For training, enter: Sample Company Ltd Invoice - %OEINVPRINT.INVOICE
  4. Use IMan Styling
    • The email will be formatted using the internal IMan styling used on the audit report. If this is unchecked it allows you to create an email using your own styling and HTML.
    • For training: Checked
  5. Embed MIME/Images into Email
    • Any images referenced in the email will be embedded into the contents of the email as opposed to being referenced as a URL or local file path.
    • For training: Checked
  1. Expand the body and enter the following, after each line press the Add button:
  1. Line 1
    • Dear %[OEINVPRINT.ContactName],
  2. Line 2
    • Please find attached your latest invoice %[OEINVPRINT.INVOICE]. If there are any queries please contact our accounts department quoting the invoice number.
  3. Line 3
    • Your current balance is $ %OEINVPRINT.Balance and we would appreciate it is kept up to date.
  4. Line 4
    • Thank you for your custom.
  5. Line 5 – In this line we add the company’s logo using some html. 
    • <a href="http://na.sage.com/sage-300-erp/"><img src="C:\IMan\InputData\SampleLogo.png" /></a>

It is important to replace the path of the image source to the actual path of a logo of your choosing.

  1. Line 6
    • Sample Company Ltd.

  1. Collapse Email Body
  2. Expand Attachments and enter the following and press the Add button:
    • %OEINVPRINT.EXPORT

  1. Press Refresh to generate the invoices.
    • If successful the Generation Status should go complete and three invoices will appear in your inbox.

  1. Press Apply to save then close.
  2. Save the integration.