Easy to Create, Easy to Change - Easy to use!


SendEmail


Started by Tor Nerland
Search
You will need to Sign In to be able to add or comment on the forum!

SendEmail

Have done some tests with the use of "SendEmail" this works well using only an attachment, but when more are admitted will be no email received, Are there opportunities for multiple attachments, if so, how shall command line formulated.

Taught how I have tried to achieve this.

sendemail -f tnerla@broadpark.no ........... -u Test2xx -o message-content-type = html -o message-file=.\ Mail\000002.htm -a.\Mail\000-000-ORDER-00002-tas-2.pdf -a.\Mail\000-000-ORDER-00002-tas-3.pdf

Have used the Memo field to the command line, so this should not be due to get ratings

Written by Tor Nerland 13/12/14 at 09:58:09 Dataease [{8}]FIVE

Re:SendEmail

Simples...

You don't add a new -a you simply space the attachments 

sendemail -f tnerla@broadpark.no ........... -u Test2xx -o message-content-type = html -o message-file=.\ Mail\000002.htm -a.\Mail\000-000-ORDER-00002-tas-2.pdf .\Mail\000-000-ORDER-00002-tas-3.pdf

Any DE function can only pass 255 bytes in an argument so it isn't much point in using a Memo as only the first 255 of the derivation will be passed anyway.

Written by DataEase 13/12/14 at 10:52:08 Dataease [{8}]FIVE

Re:Re:SendEmail

Takk for raskt svar.

Mitt neste spørsmål er: Er det noen mulighet for å omgå taket på 255 tegn som DE har ?.

Translation for our other deserving users:

Thanks for the quick answer.

Next question: Is there a way to get around the 255 limitations of DE?

Written by Tor Nerland 13/12/14 at 12:34:57 Dataease [{8}]FIVE

Re:Re:Re:SendEmail

This is a question that we deliberate over a lot to be honest.

The problem is that DE is 8 bit at "heart". This sound crazy and outdated, but in reality it is brilliant, because it means that it is blitzingly fast.

With hear we mean PRISM which in essence is really DFD turned into a DB engine.

Since it is 8 bit, you can only transfer 255 (address) characters in one argument.

With Memos we got around this by making a lot of specialized functions to work with the memo. 

In Pre-8 DataEase you never manipulated data directly, you basically derived them and returned the data to the field/variable.

MyField := concat(Myfield, "This","Is","a","Test") . 

This derivation basically concatenate the current value of MyField with "Thisisatest" in a buffer and then allocate it back to MyField.

MemoReplace(MyMemo,"Test","Bjarne") actully work within the memorybuffer where MyMemo is stored and replace Test with Bjarne.

Big difference.

When working around the 255 limitation you quick run aground.

We could change ExecuteFile() to accept a Memo but the problem would still be to build that memo since Concat() will still return only 255 and so would all other normal (historic) PRISM functions.


I was thinking that we should maybe change FileExecute to accept a Memo as an argument as you can actually have more than 8000 characters as a command line in Win8.

However you would then have to build/manipulate that Memo with Memo functions rather than the traditional Concat() way.

Until we make up our mind about that the solution for you is there.

You still have to use a Memo or WriteTofile() to build a bat file, and then exectute that bat file with ExecuteFile() instead of the command directly.

it is not elegant, but it will work.

sample dql:

define "retval" text .
retval := WriteToFile(MyFilename,concat("sendemail ", args...),1) . -- Make sure each increment is guaranteed less than 255.
retval := WriteToFile(MyFileName,concat(more args) ) ,0) . -- Append further text, repeat as many times as you like.
retvla := ExecuteFile(myfilename) -- which is a bat file.

Written by DataEase 13/12/14 at 12:44:08 Dataease [{8}]FIVE

Re:Re:Re:Re:SendEmail

Adding to the last post, we firstly need to correct the "deliberate error" in which the arguments of the WriteToFile() function appear in reversed order :-)  For anyone who is interested, the following coding will generate a .bat file which breaks down the Commandline derivation into chunks none of which should exceed 255 characters unless there's an awful lot of recipients or attachments.

define "retval" text 5 .
define "tempstring" text 255 .

retval := MemoWriteToFile(Message,concat(".\Mail\",MailID ,".htm"),1) .

tempstring := any rMailSettings_MC Send Line .
retval := WriteToFile(concat(tempstring," "),"sendemail.bat",1) .
tempstring := concat(" -t " ,MailTo ," -u ", Subject ," ") .
retval := WriteToFile(concat(tempstring," "),"sendemail.bat",0) .
tempstring := concat(" -o message-content-type=html -o message-file=.\Mail\",MailID ,".htm ") .
retval := WriteToFile(concat(tempstring," "),"sendemail.bat",0) .
if Attachment not=blank then
     tempstring := concat(" -a ",Attachment ,"") .
     retval := WriteToFile(concat(tempstring," "),"sendemail.bat",0) .
end

retval := ExecuteFile("sendemail.bat") .
Message "Email despatched" window .

 The only problem is that I cannot manage to execute the resulting .bat file using the ExecuteFile() function. I have tried it with / without the full path, with / without inverted commas, making this a button action, etc etc. However the statement  ExecuteFile(Commandline) works fine provided of course that Commandline doesn't breach the 255 character limit. What am I doing wrong please?

Thanks,

Bill

Written by Bill Nicholson 02/01/15 at 17:36:04 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:SendEmail

I am afraid that it is too late to correct the "deliberate error" of the argument order in WriteToFile(). The problem is that it is the complimentary function to MemoWriteToFile() so it has the same argument order. Obviously you are correct, and it should have had the order of WriteToFile("FileName","WhatToWrite","Mode")... This is what happens when Programmers do the logic ;-)

This is the biggest problem with publishing development sofware - everything you release will stay with you for "posterity"... 

We releases SetVar()/GetVar() as SetGlobal()/GetGlobal() conflicting with the old CDF with the same name. This would have been fine if we hadn't defined it differently (Internal functions take precedent when name is the same). We defined it with Names SetGlobal("MyVar","Value") when the CDF SetGlobal() was defined as SetGlobal(Number,"Value") ... This was early in the DE8 development but we quickly had to make a decission to either keep ours or rename it. We decided to rename ours as there has been enough "problems" with compatibility caused by DataEase and even though we could argue that SetGlobal(CDF) is not a DataEase "approved" function, it was so widely used (due to the lack of similar functionality in the standard release) that we would do more harm than good. 

Even though we quickly advertised that people should avoid using our SetGlobal()/GetGlobal() and released an update within a matter of hours we caused a lot of trouble for a surprisingly large number of users.

Since this we have learnt a lot and we focus even more than before on evolutionary development. I.e. We never change, but we add and expand. As part of this approach we can now have variable numbers of Arguments on a function, and the latest change is that we can now have both numbers and text for the same Argument. 

So SetState("MyObject",0) will now be the same as SetState("MyObject","Hide") etc. (8.3).

This way we can constantly develop DataEase when at the same time not cause users to migrate or any other grief or problems.

Written by DataEase 05/01/15 at 09:14:44 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:SendEmail

So to the issue at hand here.... and this is a "Can't see the forest for all the threes issue!"

The problem is that you call your bat file SendEmail.bat.... so you basically call your own bat file over and over and over and over again instead of calling the SendEmail file.

Calling bat files work fine, just tested it with SendEmail.

Cheers!

Written by DataEase 07/01/15 at 14:23:13 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:Re:SendEmail

I seem to be particularly slow on this one. As ever when there's a problem one should go back to first principles.

I have compiled a file called "testing.bat" with the following commands:

ECHO on
PAUSE We are now in the bat file

Double clicking on it displays the message in a DOS window as expected.

I have also created a DE button with the following action:

ExecuteFile("D:\DATABASE\DataEase 8\Samples\Just Testing\testing.bat")

Clicking the button gets no response. I know it has found the .bat file since there's no error message. What am I doing wrong please?

I would add that the description of ExecuteFile() in the CDF manual is extremely terse, almost cryptic.

Thanks.

Written by Bill Nicholson 07/01/15 at 16:09:43 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:Re:Re:SendEmail

You have a "knack" for finding/testing the things that don't work ;-)

Sorry, can't help it, just have to wind you up.

I did the same as you, and realized that ExecuteFile() will not give you any Console Output i.e. the Bat is run but any output to the black box is not displayed.

This is intentional to make the process integral to the application (no ugly black boxes).

So just test with the SendEmail script you originally made and it should all be great, but remember to rename sendemail.bat to somethingElse.bat.

Written by DataEase 07/01/15 at 18:57:26 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:Re:Re:Re:SendEmail

Look I am just an average Joe trying to develop some applications at DE's outer edge and I keep running up against these problems - I am not looking for them, honest. I created the simple test problem to get the hang of ExecuteFile(), couldn't make it work and concluded that the function was faulty. I will now try what you suggest.

It might help other users to understand the email capabilities if they visited the SendEmail website at

http://caspian.dotconf.net/menu/Software/SendEmail/

It certainly helped me to understand better what the strengths and limitations of the system are. It would appear from the FAQs that only small emails can be sent (16 kb), so don't try to send large attachments.  I also note that the last release was in 2009 so this may only be a temporary solution if it isn't going to be further developed.

In case anyone else is trying to do the same as me, here is some DQL to write the SendEmail command to a bat file. Note that Attachments are in a memo field whereas everything else is in text fields (one could easily put the email addresses into a memo field too if there's concern about the 255 character limitation). It has been tested a couple of times but not exhaustively so it isn't guaranteed bulletproof but you'll get the idea. You will also note that this is a conventional DQL procedure rather than OML (hence the "for" loop) because this is more reliable.

Necessary enhancements include:

1. To receive confirmation that the email was sent successfully (there's a Logfile facility in SendEmail which needs to be explored).

2. To post a copy of the email to a secure location so there's a record of what was actually sent.

Happy emailing!

define "retval" text 5 .
define "tempstring" text 255 .
define "nochunks" number .
define "icount" number .

for _MailClient with MailID = GetVar("MailID") ;
retval := MemoWriteToFile(Narrative,concat(".\Mail\",MailID ,".htm"),1) .

tempstring := any rMailSettings_MC Send Line .
retval := WriteToFile(concat(tempstring," "),"something_else.bat",1) .
tempstring := concat(" -t " ,MailTo) .
retval := WriteToFile(concat(tempstring," "),"something_else.bat",0) .
tempstring := concat(" -cc " ,MailCC) .
retval := WriteToFile(concat(tempstring," "),"something_else.bat",0) .
tempstring := concat(" -u ", Subject ," ") .
retval := WriteToFile(concat(tempstring," "),"something_else.bat",0) .
tempstring := concat(" -o message-content-type=html -o message-file=.\Mail\",MailID ,".htm ") .
retval := WriteToFile(concat(tempstring," "),"something_else.bat",0) .
-- the next section is for Attachments in a memo field
if Attachments not=blank then
retval := WriteToFile(" -a ","something_else.bat",0) .
nochunks := floor(MemoLength(Attachments)/256) + 1 .
icount := 0 .
while (icount < nochunks) do
tempstring := MemoChunk(Attachments,icount) .
retval := WriteToFile(concat(tempstring," "),"something_else.bat",0) .
icount := icount + 1 .
end
end
end
retval := ExecuteFile("something_else.bat") .

Written by Bill Nicholson 07/01/15 at 20:36:07 Dataease [{8}]FIVE