[SOLVED] Try to Send email :-)

Eveyrhing works like a charm, it’s all Gmail’s problem …
Don’t use gmail at all …
Here are my configurations and the result.
The only problem is the {ORDERS}

In earlier pos i wrote that i use my host settings and didn’t work, after i spoke today with Tech Department the informed me that they have a “super” security system and only they can disable it !!!
So we disable it and everything is OK

neither
is working

It seems that i can’t have {ORDER} or anything close to that on email body so i decide to print ticket to a file and have it as an attachment to an email.
I want it in pdf format, I set printer to pdf but the export file is broken …
Any idea ?

In theory if you print to text file you should be able to use a script to read that test file into the message body in pretty much whatever layout goes on ticket.
Or even a script to read direct from the orders table and generate a message body.
I have a script which generates a JSON array for each order on a ticket which should be fairly straight forward to produce a line per order body with format like;
{QTY} x {ORDER} {PORTION(if not normal)} - {PRICE}
You would just need to feed TicketId into the script as part of the email action/rule

hi @JTRTech
can you share that script ?

Find function itemized(PostTicketId) in my PMS Integration topic.

It will need some adapting…
Few parts will be irrelevant.
Also note there are a couple of dependent scripts which are being loaded at the top of the script, you will also need these either as part of it or dependent like mine.

1 Like

something more simpler is a script to read the txt file and the body will be a {CALL:???.???}

Have a look at this topic.
Was based arround reading a txt file.

1 Like

My file export name is c:\tickets\{DATE:ddMMyyyy-HHmmss}.txt

with this simple script i call it in my email {CALL:read.ticket}, but the email is empty
so i supose that {DATE:ddMMyyyy-HHmmss} is not valid for script ?
even with fixed name still not working …

Handler: read

    function ticket() {
      var ticket = file.ReadFromFile('c:\\tickets\\{DATE:ddMMyyyy-HHmmss}.txt');
      return ticket ;
    }

i confirm for those who don’t own domain name/hosting that outlook.com with the following settings is working.

S M T P Server: smtp-mail.outlook.com
S M T P User: youremail
S M T P Password: yourpassword
S M T P Port: 25
To E Mail Address:
Subject:
C C Email Addresses:
From E Mail Address:
E Mail Message:
File Name:
Delete File:
Bypass Ssl Errors: False
Retry Count:
Retry Minutes:

Use {TICKET ID} for file name in print action.

Then change to;

function ticket(inputTicketId) {
      var ticket = file.ReadFromFile('c:\\tickets\\'+inputTicketId+'.txt');
      return ticket ;
    }

Then your call will be;
{CALL:read.ticket({TICKET ID})}

PS. even if {DATE:ddMMyyyy-HHmmss} did work in tickets its within quotes so would be treated as a string not a variable
file.ReadFromFile('c:\\tickets\\{DATE:ddMMyyyy-HHmmss}.txt');

Thats what the + + is about;

var ticket = file.ReadFromFile('c:\\tickets\\'+inputTicketId+'.txt');
'c:\\tickets\\'   +   inputTicketId    +     '.txt'
^^^^^^^^^^^           ^^^^^^^^^              ^^^^
 string        plus     variable      plus    sting

So is inputTicketId was 12345 it becomes;
var ticket = file.ReadFromFile('c:\\tickets\\ 12345.txt');

'c:\\tickets\\Ticket: ' + inputTicketId + '.txt'

So your filename would be 'Ticket: 12345.txt'

1 Like

For some reason Samba is searching for 0.txt
and the output file name is {TICKET ID}.txt
with ticket id i started in first place and then i set it as date format

[Exception Info 1]

Top-level Exception
Type:        System.IO.FileNotFoundException
Message:     Could not find file 'c:\tickets\0.txt'.
Source:      mscorlib
Stack Trace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at System.Net.Mail.AttachmentBase.SetContentFromFile(String fileName, String mediaType)
   at System.Net.Mail.AttachmentBase..ctor(String fileName)
   at System.Net.Mail.Attachment..ctor(String fileName)
   at Samba.Services.Implementations.EMailService.<>c__DisplayClass3_0.<InternalSendEmail>b__2(String x)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at Samba.Services.Implementations.EMailService.InternalSendEmail(String smtpUser, String smtpPassword, Int32 smtpPort, String toEmailAddress, String ccEmailAddresses, String fromEmailAddress, String subject, String body, String fileName, Boolean bypassSslErrors, MailMessage mail, SmtpClient smtpServer)
   at Samba.Services.Implementations.EMailService.SendEmail(String smtpServerAddress, String smtpUser, String smtpPassword, Int32 smtpPort, String toEmailAddress, String ccEmailAddresses, String fromEmailAddress, String subject, String body, String fileName, Boolean deleteFile, Boolean bypassSslErrors, Int32 retryCount, Int32 retryMinutes)

Is your evnt still ticket entity changed?

Expect your doing a new ticket, {TICKET ID} wont work till ticket is submitted/saved.
Try laying it away to a table reopen it and then change entity.
You will probably need to add a save ticket action in at the top on the rule actions.

OR

You could try using {TICKET NO}

When you get it working would love to see a screenshot of the resulting email to see how it comes out.

You could get fancy as email body should support HTML so you could add some ''pretty" formatting.

1 Like

{TICKET NO} - no working
{TICKET ID} - no working
{DATE:ddMMyyyy-HHmmss} - it’s working

Did you try adding a save ticket action;

If you want to use dat you can but you will need to do a two stage automation.
Execute automation command with date as the command value
That command triggers your existing rule and [:CommandValue] would be used in place of {DATE} in both actions.
I dont think using DATE twice will work as seconds are possibly going to change between them…

SAYING THAT!!!

Unless you want to been a log of the .txt tickets you could just used a static file name in both as reprinting next ticket should overwrite. Just make sure file directory is local if using multiple terminals to avoud clashes.

i prefer Ticket No and not date.
I use date because it was the only working for create ticket to file

Add a save ticket action and put it first in the list of actions on the rule.

Personally I doubt that entity changed would be the best place to trigger the rule anyway, what if you select wrong one…
Or if the entity were selected before completing the ticket and more orders added after selecting entity?
Why not of ticket close?