Sendemail - pick up field variable
Up to now I have been using the built in Ninox Email field, which to be fair is not bad.
but of course this then triggers my default email client (ie outlook).
Good feature is that i can pick up field data and have is apart of the subject or email body
Subject Line:-
Order confirmation from 118 printgroup - Job {'Job Bag'} - {Desc} - Your ref {'Order Ref'}
Email Body:
Our Ref: {'Job Bag'} Date: {'Order Date'} Your Ref: {'Order Ref'} Item: {Qty} {Desc}
Thank you for placing your order with us
etc etc
The down side is I can't append attachments (other than by adding them at outlook end)
So i am looking at Nixon SendEmail
I have my body (which is all working fine ) but I can't see how I can add the field variables
can someone point me in the right direction please - this is my script (so far)
ie i want to get this line
Our Ref: {'Job Bag'} Date: {'Order Date'} Your Ref: {'Order Ref'} Item: {Qty} {Desc}
into this script somewhere - where it will work (ideally within the hmtl section?)
let myPdf := printAndSaveRecord(this, "test");
let myName := "Order Confirmation.pdf";
importFile(this, myPdf, myName);
sendEmail({
from: "sales@testcompany.co.uk",
to: 'ContactEmail',
subject: "Order Acknowledgement from 118 Printgroup",
text: "Test ",
html: "<h2>Order Acknowledgement from 118 Printgroup:</h1>
<br><b>
***** Thank you for your order - Print Order Confirmation *****
<br><br></b>
Thank you for placing your order with xxx.
We confirm that your order has been successfully received and is currently being processed.
We will keep you updated regarding any visuals and production schedule/delivery timescales.
<br><br>
We value your business and are constantly looking for ways to better satisfy our customers.
Please do share with us if there is a way that we can serve your better.<br>
If you wish to discuss your order in person please do call our customer services on
xxxx and quote our job reference number {'Job Bag'} (i have left this ref in as an example - as it stands it is treat as just text on the output)
<br><br>
</h1><b>Test Company Limited
</h2><b>Salesl: 0123 456 789
</h2>sales@testcompany.co.uk",
attachments: file(this, "Order Confirmation.pdf")
})
4 replies
-
okay sorted this
i can use the replace function
when I have finished and got it fully working I will post it back it up here for others to see how its done
-
Have a slight issue with sendMail. insofar as
the last full line in bold !!!
This button is on my jobdockets form and when the attachment is on the same form I can pick up the attachement using this etc. no problem
However I want to have the attachment in the first record of a foreign table - hence the above line
this produces no script error but simply ignore picking up the attachment!
Ie the script creates an order confirmation and attaches into the current record as a copy
then also sends out the html version - for whcih I want to attach to that email the product overview pdf.
let myPdf := printAndSaveRecord(this, "test");
let myName := "Order Confirmation.pdf";
let thisBody := first((select SystemFile).Body);
let myEmail := userEmail();
thisBody := replace(thisBody, "{Job Bag}", text('Job Bag'));
thisBody := replace(thisBody, "{Order Date}", text('Order Date'));
thisBody := replace(thisBody, "{Order Ref}", 'Order Ref');
thisBody := replace(thisBody, "{Qty}", text(Qty));
thisBody := replace(thisBody, "{Desc}", Desc);
thisBody := replace(thisBody, "{Total Sell}", text('Total Sell'));
importFile(this, myPdf, myName);
sendEmail({
from: myEmail,
to: "james@118printgroup.co.uk",
subject: "Order Acknowledgement from 118 Printgroup",
text: "test only ",
html: thisBody,
attachments: first((select SystemFile)."118 Product Overview.pdf")
})any suggections would be welcomed :-)
Cheers
Mel
-
Maybe use :
let att := record(SystemFile,1).Attachmentfield >(In case you used a Image field to put your pdf in, if not try: first(files(record(Systemfile,1)))
and in your sendEmail use
...
html: thisbody,
attachments: att
})
Steven
-
Cheers Steven
Worked a treat! You are a star!
Mel
Content aside
- 3 yrs agoLast active
- 4Replies
- 593Views