Send email with Sendgrid

Webhook

To use this webhook and send email messages you need to create a Sendgrid account and create an API key.

This example sends a Purchase order with payload in HTML  to your suppliers emailaddress with your own Sendgrid account.

Method: Post

URL: https://api.clougistic.com/eu/version/email

Events: 

warehouse.supplier.purchase.status.confirm.after

warehouse.supplier.purchase.status.processing.after

Headers:

Content-Type: text/html

Authorization: Your Sendgrid API Key

Mail-From: Your e-mail address

Mail-From-Name: Your Company name

Mail-To: {{$supplier.email}}

Mail-To-Name: {{$supplier.name}}

Subject: {{$getTypeText()}} Order {{$id}}

Payload:

<html xmlns="http://www.w3.org/1999/xhtml"><head>    <meta http-equiv="Content-Language" content="nl-NL">    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">    <title>{{ $getTypeText() }} Order</title></head><body bgcolor="#fafafa" style="background-color: #fafafa" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0"><table width="100%">    <tr><td>            <table style="border: 1px solid #999;" width="100%">                <tr>                    <td align="left">                        <img src="{{ $entity.getCompany("logo_url") }}"/>                        <h3>{{ $entity.getCompany("company") }}</h3>                        {{ $entity.getCompany("address") }}<br>                        {{ $entity.getCompany("postcode") }}<br>                        {{ $entity.getCompany("city") }} {{ $entity.getCompany("country") }}<br>                        <br>                        <table>                            <tr>                                <td align="left">Email<br>Phone<br>Fax</td>                                <td align="left">{{ $entity.getCompany("email") }}<br>{{ $entity.getCompany("phone") }}<br>{{ $entity.getCompany("fax") }}</td>                            </tr>                        </table>                    </td>                    <td align="right"><h2>{{ $getTypeText() }} Order</h2><br>                        <table>                            <tr>                                <td align="left"><b>PO Number<br>Purchase Date<br>Terms of Delivery<br>Terms of Payment<br>Currency<br>Delivery Date</b></td>                                <td align="right">{{ $id }}<br>{{ $created_at }}<br>{{ $shipping_term }}<br>{{ $payment_term }}<br>{{ $currency }}<br>{{ $etd }}</td>                            </tr>                        </table>                    </td>                </tr>            </table>            <br>            <table style="border: 1px solid #999;" width="100%">                <tr>                    <td align="left" width="50%" valign="top"><h2>To</h2>                        {{ $supplier.name }}<br>                        {{ $supplier.firstname }} {{ $supplier.lastname }}<br>                        {{ $supplier.address }}<br>                        {{ $supplier.postcode }}<br>                        {{ $supplier.city }} {{ $supplier.country }}<br>                    </td>
                    <td align="left" width="50%" valign="top">                        {{if $comment}}                        <h2>Comment</h2>                        {{ $comment }}                        {{/if}}                    </td>                </tr>            </table>            <br>
            <table style="border: 1px solid #999;" width="100%">                <tr>                    <th align="left">Partnumber</th>                    <th align="left">Product Description</th>                    <th align="left">Order Reference</th>                    <th align="left">Custom Options</th>                    <th align="right">Qty</th>                    <th align="right">Unit Qty</th>                    <th align="right">Unit Price</th>                    <th align="right">Subtotal</th>                </tr>                {{for $item in $items}}                <tr>                    <td align="left" bgcolor="#ffffff">{{ $item.pn }}</td>                    <td align="left" bgcolor="#ffffff">{{ $item.name }}</td>                    <td align="left" bgcolor="#ffffff">{{ $item.orderItem.order.reference }}</td>                    <td align="left" bgcolor="#ffffff">                  {{ if $item.getOrderItemOptionData() }}                        <table>                     {{ for $option in $item.getOrderItemOptionData() }}                                 <tr><td align="left" bgcolor="#ffffff">{{ $option.label }}</td><td> {{ $option.value }}</td></tr>                     {{ next option }}                        </table>                 {{ /if }}                    </td>                    <td align="right" bgcolor="#ffffff">{{ $item.qty }}</td>                    <td align="right" bgcolor="#ffffff">{{ $item.unit_qty }}</td>                    <td align="right" bgcolor="#ffffff">{{ $item.unit_price }}</td>                    <td align="right" bgcolor="#ffffff">{{ $item.getSubtotal() }}</td>                </tr>                {{next item}}            </table>
            <table style="border: 1px solid #999;" width="100%">                <tr>                    <td align="right">                        <table>                            <tr>                                <td align="left"><b>Total</b></td>                                <td align="right">{{ $getItemAmount() }}</td>                            </tr>                        </table>                    </td>                </tr>            </table>
            <table style="border: 1px solid #999;" width="100%">                <tr>                    <td>                        <h2>Terms and Conditions</h2><br>                        {{ $supplier.getTermsAndConditions() }}                    </td>                </tr>            </table>        </td></tr></table>
</body></html>