Create and read emails in VB.NET
Email is a powerful tool in today’s way of communicating. It costs nothing to send an email and it has instantaneous delivery regardless of where you are in the world. People can send and receive emails on the web, download to their PCs, using their Pocket PC and mobile phone. It costs virtually nothing to set up and is a widely recognised form of communication everywhere in the world.
But why stop there? Why not have our application generate emails and send them to the relevant people. Why can’t a sales manager receive an email with the daily statistics of their field agents? How about sending an email to the mobile users and have them receive the message right from within their business application. Customers could get an invoice emailed to them right at the point of sale and not sometime later.
The problem is to allow our eVB or VB.NET/C# applications to generate these emails. Sapphire Solutions (http://www.sapphire-solutions.co.uk) have come up with a solution, the Sapphire Mail Utility. It works with the mail box settings configured on the Pocket PC device.
The Sapphire Mail Utility is a small DLL that can be called from within eVB or VB.NET/C#. It interfaces with the devices’ mail box and can read the contents of the inbox as well as generate outgoing messages. You can also attach a files to that and create an entirely new mailbox.
The Sapphire Mail Utility has the following features:
Running the demo project
Sapphire have also provided an extensive demo project in both eMbedded Visual Basic and VB.NET that show how to use all the functions of the DLL. You get all the eVB and VB.NET source code which is not only great for experienced programmers to implement the utility, but also great for new programmers to see how the application has been approached.
The latest version of the Sapphire Mail Utility can be downloaded from their web site here:
Once you have downloaded the demo project and unzip it, you will have two versions of the demo project, one for eVB and the other for VB.NET. You will also have a folder containing the different DLLs compiled for the different devices.
Simply select the DLL that matches the device. If you are developing in eVB, then you will need to copy the DLL to the \Windows\ path. Alternatively, if you are developing in VB.NET or C#, you need to copy the DLL to the application path. Check the project settings to see where the demo project will deploy itself to.
Now you are ready to run the demo. Please note the following screenshots have been taken from the VB.NET demo project.
Sending an email
Reading an email
List of message in Draft or Inbox folder
Read email with option to save attachement
Public Function CreateMail(ByVal sTo As String, _
ByVal sCc As String, _
ByVal sBcc As String, _
ByVal sSubject As String, _
ByVal sBody As String, _
ByVal sAttach As String, _
ByVal sService As String, _
ByVal lFolder As Integer) As Integer
CreateMail = sCreateMail(sTo, sCc, sBcc, sSubject, sBody, sAttach, _
sService, lFolder, SapphireMailLicence)
Public Sub ReadMail(ByVal sService As String, _
ByVal lFolder As Integer, _
ByVal lReadEntry As Integer, _
ByRef sSenderName As String, _
ByRef sSenderEmail As String, _
ByRef sSubject As String, _
ByRef lAttachment As Integer, _
ByRef sBody As String)
Dim sReadSenderName As String
Dim sReadSenderEmail As String
Dim sReadSubject As String
Dim sReadBody As String
Dim lReturn As Integer
sReadSenderName = Space(1024)
sReadSenderEmail = Space(1024)
sReadSubject = Space(1024)
sReadBody = Space(1024)
lReturn = sReadMail(sService, lFolder, lReadEntry, _
sReadSenderName, sReadSenderEmail, _
sReadSubject, lAttachment, sReadBody, _
sSenderName = StripString(sReadSenderName)
sSenderEmail = StripString(sReadSenderEmail)
sSubject = StripString(sReadSubject)
sBody = StripString(sReadBody)
The Sapphire Mail Utility is a great product for sending and receiving emails. Additional to this, a great complimenting product is the Sapphire GZip Utility that can zip up multiple files in to one single compressed file compatible.
Sapphire Solutions also provide a comprehensive manual for all their utilities. It includes a definition of the DLL function calls, some sample code and FAQs to help with any troubleshooting.
Their manual documentation can be viewed online, downloaded as a HTML document for offline use and even a downloadable Windows help file. These can all be found on their web site at http://www.sapphire-solutions.co.uk/manual.
Licence of use
Sapphire Solutions provide an unlimited use demo version of the Sapphire Mail Utility. While the product will function as normal, the user will receive a popup message stating that it is a demo version. It is great for trying out the utility, checking device compatibility, building it into your application and selling the idea to your customer. Students can use it as well for their college or university projects without having to purchase it either.
Of course though, for commercial applications being developed you will need to get a licence for the utility to make it run without any pop-ups. The good thing about Sapphire’s pricing policy is that it is a one off fee and you or your company can use it as many times as you like for your projects royalty free. There are no royalties required for rolling out your application to your client.
With that you will also get 12 months support via email to their experienced technical team. They also provide upgrades for the latest versions at discounted prices which also extend the 12 months support by a further 12 months.
|Copyright © 2004, CFVB.NET. All Right Reserved.|