Simplicty and flexibility!

New Feature! Emailing and PDF from DE8.2

We have had emailing and PDF generation in DataEase 8 for quite a while but the library we used for emailing didn't support TLS so it could only use a limited number of SMTP servers. We have also shown how you can generate PDF to a named file, but the solution wasn't very elegant and the documentation was rather lacking.

We have know made a small Email and PDF application that you can download, explore and test and hopefully it will now become part of your DataEase "vocabulary".

You will need minimum DataEase 8.2.0.1986 to run this application.

Download Email and PDF sample
This is not an article but a quick explanation of the sample application attached so you can "steal" the features we use. 

1. Downloading and installing this sample.

When you have downloaded the sample simply click on it and Unzip it. It will ask you where to unzip and you can unzip it anywhere but it would be a nice idea to unzip it in My DataEase under Samples or something like that.

When you have unzipped it the content of the catalogue will look like this:

This is the new way we present Samples where all the DE files are hidden and only the new startup files are shown.

To start the sample simply click on the Startup Application. 
(The new Startup feature is to make it easier to navigate in DE apps. Especially if you have many different versions of the same app. Before you had to locate where the app was and then open it from there, but now you can simply use the explorer and find the app then click on the Startup.exe in the catalogue and it will do the rest.

The Startup.ini is not necessary but if you use it you can specify which DataEase to open, (Runtime of Developer), what app to open and what user/pw to use etc.)

Our Startup.ini looks like this:

[STARTUP]

AppPath=.

Program=DataEase.exe

AppName=Emailing And PDF

UserName=High

Password=High

2. Running the sample.

When you start the application it will go straight to the form Landingpage. This form is basically a navigation central for the app. It will check if you are running a new enough DataEase 8.2. 

The checking is done in the virtual field Manip (Look for Manip fields in our Samples as they are the magic fields).

Virtual fields are magical as the are executed on load and also if any dependences are "touched". i.e. fields that are included in the derivation of the virtual field.

This is the derivation of our Manip:

MoveObject("Record1","C","C")+if (lastc(GetCurrent("Version"),4)+0 >=1686, if (AnySettings = 0, DocumentOpen("Mail Server Settings"),DocumentOpen("Simple Mail Client") ) ,DocumentOpen("VersionToOld"))+SetState("Manip",0)+SetState("AnySettings",0)

MoveObject("Rrecord1","C","C") you can just make a note of immediately if you haven't already used it. This basically move the record object of the form to Center Center, and is a magic command. It is a very simple use of the MoveObject function as you will see when we get to the Simple Email Client form...

You will need to resize the Record object to be able to use this feature, but in 8.2 you can... 

The next we do is to read out the last 4 characters of the version number returned with the new GetCurrent("Version") feature. This is the build number of DE and as the features used in this app is only available from 1686 this is the cutoff point we put it.

If the Version is lower than this we open the form. VersionToOld, if the version is OK we check if there the Mail server settings have been set. If they haven't we opwn the form. "Mail Server Settings".


3. Configuring the Mail server. 


In this sample we only have one record for server settings when you in a real app would be likely to have one pr. user etc. This is a sample, so it is not for actual use but for inspiration and education. 

We have made it easy and only included the features necessary to get this plane off the ground and it should be qutie straight forward.

This is standard SMTP settings (you get them from your email provider) ans is the same stuff you would use in Outlook etc. 

Our sample here is for setting up GMAIL as our SNTP provider. This is a free service and it is interesting because it uses TLS security which was a problem with our old setup.

You can see the command string generated in Command Line and this si the one that we will use for the Test Mail and the white Command Line further down is the one we use for actual mail sending in "Simple Mail Client". Configure all the settings and save them and hit Send Test Mail. When you receive the mail in your designated mail account you are ready to go on. 

Up in the Right corner you will find a menu that will take you to the SImple Mail client. This menu showcase another new feature which is to create navigators and objects directly on the form object, and then move it to a designated position on open. We here see that we have three independent objects that has been deployed independent of each other 1) Heading, 2) Main Record Body and 3) Menu.

4. Sending Email

This email client shwocase more than simply sending mail. It also showcase MoveObject to jog your imagination. Here we move and resize the objects so that it will fit to your screen (have a look in design mode and see the difference).We also employ the updated HTML Editor object for body so you can RT emails, and we showcase how you can use a Subform as a pick list with some Set/Get and move magic.

This is a very simple mail client but it is very advanced DataEase and you should be able to pick up a lot of tricks so you can implement this feature in your apps properly.

If you want to pick an addresse for your email simply clcik the blue question mark to the right and you will get the pick list. Pick a client or click on Addressbook to go and add a new one.

Fill inn the subject and edit your RT mail in the ditor with font's images etc.

When you are happy you can simply hit PDF and the new PDF tool will render a PDF attachment of the body, the code you will find it DT.

When you are happy, simply hit Send button and the mail will go away.

That should be it for now. Go to design mode and dig into the code. There is a lot of useful hints and trick and if there is things you don't get, just write a comment on the forum and we will explain and showcase it for you.

Published: 14/11/14 - 16:56:36 (Mr. DataEase)

Related Articles

New Feature! Emailing and PDF from DE8.2