Day 041 - Email and FTP
There's a two-page section on FTP in the tutorial, which like yesterday's sockets documentation doesn't come close to covering all of the possibilities.Â
There are three FTP sample apps: one covers just basic FTP file transfer, another shows how to use threads, and the third shows how to use an internal window to display progress information. Internal windows are another one of those really useful things about WinDev as they allow you to reuse UI code.Â
I won't go into the details of the FTP examples. I did have a look through the code, and it seems to me that WinDev does a pretty good job of wrapping up FTP access so it's less painful than usual.Â
It's important to keep in mind that FTP alone isn't secure - although you can require a login for an FTP server, FTP passwords are sent in plaintext.Â
There are several ways to do secure FTP transfers, but I wasn't able to find any such support in WinDev itself. You'll probably have to use an external library or utility.Â
WinDev has built in support for sending email, and supports the POP3, SMTP, Outlook, Lotus Notes and IMAP protocols. Emails can be plain text or HTML (and I would hope both, but I'm not sure.
A number of sample apps are included with WinDev:
The WD Mailshot example caught my eye. As you might have guessed, this is a bulk mail example. You select the recipients and then execute the following code:
FOR ALL ROW OF TABLE_Customers // if the customer is part of the recipients IF TABLE_Customers.COL_Checkmark THEN TableSelectPlus(TABLE_Customers,TABLE_Customers) COL_Report[TABLE_Customers]="Current" // Customize the message sMsg=sPrepareMessage(EDT_Message,TABLE_Customers) // Send the message bOK=bSendMessage(COL_Email[TABLE_Customers],EDT_Object_,sMsg,EDT_Attachments) IF NOT bOK THEN IF NOT gbSessionOpen THEN COL_Report[TABLE_Customers]="Cancelation" BREAK ELSE COL_Report[TABLE_Customers]="Fail" END ELSE COL_Checkmark[TABLE_Customers]=False COL_Report[TABLE_Customers]="Sent" END END END HourGlass(False) IF bOK THEN Info("Sending successfully completed.") END
While I was looking through this code I noticed some navigation options for the first time. I wanted to jump to the sPrepareMessage code, so I right-clicked on that procedure.Â
Note the Go to process and Return options, each of which has an associated hot key. I found the hot keys very useful - pressing F2 took me to the procedure's source code, and pressing Ctrl-F2 took me right back to where I was (as did the web browse-like green navigation arrow on the toolbar).Â
I also played around a little with the cross reference feature, which lists all places in the app where the selected code element appears. You can then navigate to the selected instance. There is also a modeling option but I didn't come across any situations where it created any kind of a graph, so I'm probably misunderstanding how that bit works.Â
As with the FTP example, while the idea of sending and receiving emails seems simple, things can get complex in a hurry, especially when you want to keep the UI responsive while email transfers are happening. Throw in attachments and HTML encoding just to keep it interesting.Â
There's a reason there are so many email examples included with WinDev.Â
Â
Â
Â