A customer of mine wants to automatically send salesinvoices when they are posted.
Personally I was thinking of adding a functionality in the button “Functions” in the sales invoice, something like “Post and email”. Where the emailadress should be taken from the customercard for the customer that is used in the sales invoice header.
Too bad I am not a developer, so if someone could tell me if this is possible, and, more important, how to do it, I would be very [:D].
Thank you for your reply. Unfortunately, the way you mentioned is one I already thought of, but is not the way my client wants.
What they want is to add another function to the "Post"button, called “Post & Send”, for example. This should trigger a codeunit, or a batchreport, don’t know which one, though.
This report/CU should take the emailadress as stated on the customercard, belonging to the customer in the sales header, open outlook, take the correct email adress, merge the invoice in the mail, and send it. And that for a number of invoices.
Best would also be to have a message that states “x out of y invoices have been sent.”
because the last applies to ONE invoice (no need for message “x of y”), but first is applicable to “batch posting” of several Invoices.
Then you may suggest different approach - after posting a bunch of SI – or every hour / every evening etc – you run a Batch Job, which emails them all at once, previously you set some filters like Posting Date or SI number from-to, whatsoever.
This needs some coding, but, as I wrote, biggest problem here is not coding, but creating image of SI to send. Try the simple scenario and look at the HTML result - it differs dramatically from printed SI. One suggestion here - “print to PDF”, and send the PDF.
It can be done, but real C/AL coding goes beyond my competence - so I’ll move this thread to Developers forum - noone is capable to read all threads here, and there it will get Developers attention sooner.
it works.
but i’m stuck on 1 thing. i tried to use: format(variables+’’) and such as, in order to create new line. but it fails.
can i ask how to force a new line for the message body.
i prepare ‘emlbody’ as text 1024 for email body, and harversting emlbody += format(record.field+’’) from all over the sections.
(I guess you are using a NAV prior to NAV 5)
When using Outlook you’ll probably will be asked to confirm “…allow another program to use Outlook…”, and if you are sending say 100 documents you have to press “Yes” 100 times. Yes - you can make some changes in the Registry to avoid this - but don’t do that!
It’s possible to use SMTP-mail which is used in NAV 5.
I tried to copy theese objects from NAV 5 till NAV 3.60: Codeunit 400 (SMTP Mail), table 409 (SMTP Mail Setup) and form 409 (SMTP Mail Setup) - and after a setup on the Exchange-server mail is sent directly via Exchange and not Outlook.
Using SMTP causes that you will not se in your Outlook that you have sent a mail; solution is to send a CC- og BC-mail to yourself.
amol, thank you for your help so far.
i think i didnot make myself clear with my question - sorry -, so, i would rephrase it:
with cu397, i assigned text into an ‘emltx’ variable - text - 1024.
i do like this: emltx := ‘Customer :’ + customer"name + ’ ’ ; emltx += 'Address : '+ customer.“address 1” + ’ '; emltx += customer.city;
with codes like this, if i output it to a text box (either in form, report or message) - with TextBox - SourceExpr:emltx;
it will give us result like this: Customer : Some Customer Address : Any Street CertainCity
but if i use: emltx := Newmessage(To,CC,Subject, emltx , Attachfilename, opendialog); as a result, an ms outlook new email appear; To., CC, Subject are correct - but - the message body appear like: Customer : Some Customer\Address :Any Street\CertainCity
obviously this is not the format i want to see in the email body. i need NAV to process’’ sign as a new line command. how to make or force a new line to appear in the email body?
I thank you very much for the feedback you’ve given.
A friend of mine created something a while ago, that uses the SMTP-server (no need for accepting use of outlook).
He made it in a way so user just prints invoices just as usual.
Then during the printout, NAV determines whether or not the particular customer wants their invoices through mail which would cause a pdf-file to be created, and mailed to the customer, or they want an oldschool paper invoice by snail-mail which would cause the invoice to print as normal.
I’ve never looked into what he created, but i remember he told me that all you need is to add a few lines of code in the existing sales invoice report.
(besides implementing a number of other objects he made, do some needed setup, and installing the automation to create the pdf locally)
If you want me to, i can contact him to hear if he still has that thingey lying around?