Sending mails, using NetExtender
I have been playing around a bit with NetExtender by eTechnologia from Colombia, these guys do some nifty work if it comes to opening the .Net framework for vfp users, it also enables us, VFP addicts, to share some of the datapower of the fox with those poor guys and galls who are so sick to use .NET as is.
One of the pretty features I found is that it is possible to send an email with basically 5 lines of code.
It could use a bit of tweaking to make it a bit more robust, but here are the lines:
omail = clrCreateObject("system::net::mail::mailmessage", ;
"MailaddressOfSender",;
"MailaddressOfReceiver",;
"Subject",;
"text to send")
This one line creates a mailmessage object. I found that adding the 4 parameters, while creating the mailmessage object, is the simplest way to create such a mailmessage.
The next line makes clear that this message is in HTML format,
omail.isbodyhtml = .t.
The next line is this:
osmtp = clrCreateObject("system::net::mail::smtpclient", ;
"URLToTheMailServer", 25)
This line creates the smtp client, it takes two parameters, the first one is the URL to the mailserver.
It should look like mail.yourserver.com or smtp.YourServer.com
The second parameter is the port of the server.
If your server requires authentication to send e-mails you need to use the following code:
ocred = clrCreateObject("system::net::NetworkCredential",;
"YourUserNameOnTheServer", "YourPassword")
Then you need to add the credentials to the smtpclient object, here is the rocket-science line for it:
osmtp.Credentials = ocred
OK, maybe you need to sit back for a moment. The hardest line is this:
osmtp.send( omail )
![Wink [;)]](/emoticons/emotion-5.gif)
The clrCreateObject() function I used in the code is one of the function provided by eTechnologia. There are a few more. I will show them, and their usage, in following blogs.
I will keep on playing with the NetExtender.
I will keep you bugging with short notices on useful things I found.
You didn't really think you could get rid of me that easy? NO WAY! ![Stick out tongue [:P]](/emoticons/emotion-4.gif)
NetExtender really is very affordable. 120 dollars is not much at all, for those in the Euro zone, this comes down to about EUR 75.
By buying the package you not only get the NetExtender for VFP but also the Net Compiler for VFP, It turns VFP code into .NEt assemblies, executables and, since the latest update, it also enables you to use foxcode behind your aspx pages.
The product has now a bit more than 50% of the VFP features implemented and the progress of the work is going on and on. In my opinion this initiative, along with Graig Boyd's VFP Studio makes the fox stronger than ever. Foxes never die, they re-incarnate in new bodies. (Hmmm, or is this a cat in a cloaking device, meaning this fox/cat should have 9 lifes.)
What I see happening here is that due to the support from our own community an interesting development started. MS let us off the leash. At least now we know for sure that there will be no marketing around the best product ever at least from the side of MS. (Not that they ever did much, but that is common knowledge.) Due to the community itself the fox lives on, in another form maybe, but still as productive and fast as we are so used to. With these developments we can blow other developers right out of the water.