Mail plugin with pop3 support

New mail plugin for Servoy 2.1
Steps to use new mail function:
-Place the plugin file in the plugin folder
-Start Servoy, open mail preference tab and specify pop3 server
-Open solution, create a method
-Move the sample code from recieveMail function in to the method
-fillin the correct username/password parameters in the call to recieveMail
-run the script
-view the output tab in the debugger (thats where application.output can be viewed)

Thanks to ‘Stef Compeers’ to for testing.

http://downloads.servoy.com/beta/2.1_product/mail.jar

This is brilliant! This sort of saves my life messing around with those beans!!

Of course, I do have some wishes though:

  1. could we have access to server settings (a user might have several accounts etc.) and pass them on to the plugin?
  2. could we have a possibility to first get the number of messages and then retrieve one message (by index) instead of all? (If you leave messages on the server then you always transfer them all even if you just want to transfer the latest)

Related to that I’d have the request of sending mail from the client via user-definable accounts.

In our (non-Servoy) application users were able to configure as many email accounts as they want and use one of them for sending and any or all of them for receiving. I need to get this working in Servoy and had lots of trouble with beans (at least the pop3 beans). And now we are very close to what I need…

Thanks for the great effort and responsiveness regarding this issue!

GREAT stuff. Work like a charm!

Beware though. Dont’ make the same mistake I did you have to provide the method with an account name NOT a complete mail adress :oops:

I think the checking on duplicate stored mail can be done with the id: Message-id=000101c49374$4c663d15$e87dbb49@aactive.com.

But then again if you want to check the header you also need to load the header…

Thanks Jan!
This is great!

would be great to have
var msgs = plugins.mail.recieveMail(‘login’, ‘pasword’, ‘incoming mail server’, true);

TIA
Stef

IT2BE: Yes I know (about the message ID), the problem is this:

Let’s say you leave messages on the server. Let’s say you have 100 messages with attachments and so on. Now you want to retrieve the new messages.

With the plugin now you will have to retrieve all 100 messages (including attachments and all) to be able to figure out that 97 of those you already had… You see the point?

What I would like to do is this:

plugins.mail.openConnection(server, port, user, pass); // establishes a connection to a given server
var no_mails = plugins.mail.getNoOfMessages(); // returns the number of messages on the server
var messageIds = plugins.mail.getMessageUIDs();  // returns an array of message IDs
var message = plugins.mail.getMessage(index int/message ID); // retrieves one message either for a given message index or a message ID
plugins.mail.closeConnection(); // closes the connection

Very useful is also something like plugins.mail.getHeader(index int/message ID). With this you might have a possibility to not completely retrieve a message. Imagine you work over a slow line and don’t want to download attachments. With header info you could be able to see the size of a message and implement an option to not fully retrieve mails larger than xxx KB.

This would be perfect!!

Is this possible??

you tell it like I couln’t get it from my brain to the screen…

huh?

New mail plugin for Servoy 2.1

REALLY, REALLY WONDERFULL!! :D

would be great to have
var msgs = plugins.mail.recieveMail(‘login’, ‘pasword’, ‘incoming mail server’, true);

Is it possible? We have a seperate pop3-box for every user!

Jan can you tell us a bit more, of the way it works? Is the mail now downloaded on the server and send to the clients?
Or is the mail downloaded right on the client itself?

looks like it is downloaded on the client.

Just noticed some problem: I get rather often a null for getHtmlMsg() and getPlainMsg(). Could there be a problem with text coding or something? The messages that have that problem display just fine in Outlook…

HJK:
We have a seperate pop3-box for every user!

We are working on a version which support:
recieveMail(userName,password,leaveMsgsOnServer,[recieveMode],[onlyRecieveMsgWithRecieveDate],[overridePreferencePOP3Host])

HJK:
tell us a bit more, of the way it works?

The mail plugin exist of 2 parts clientplugin/serverplugin+libs, the client downloads the 38K client plugin
Client does always a call to the server (plugin) and the server code makes the connection to smtp/pop3 server analizes the data get from the smpt/pop3 and sent a reponse to the client.

patrick:
Just noticed some problem: I get rather often a null for getHtmlMsg() and getPlainMsg(). Could there be a problem with text coding or something? The messages that have that problem display just fine in Outlook…

I wonder how thats possible, the bodyparts in a mail have mimetype “text/html” or “text/plain” the plugin sets the according field in the MailMessage received, all other mimetypes become attachements.

This is probably where my messages end up: in the attachments. I will investigate this further.

I just noticed that in the debugger most of my messages had no body although they do. I supposed that they are some kind of a mixed mime/type that Outlook perfectly displays.

I had similar problems before with beans. Most of the messages that gave me trouble there came from Apple Mail…

http://downloads.servoy.com/beta/2.1_product/mail.jar

enhanced version containing several requests:
the method does now look like:
recieveMail(userName,password,leaveMsgsOnServer,[recieveMode],[onlyRecieveMsgWithRecieveDate],[overridePreferencePOP3Host])

see the sample code for usage

IN one word… WOW…

patrick:
Just noticed some problem: I get rather often a null for getHtmlMsg() and getPlainMsg(). Could there be a problem with text coding or something? The messages that have that problem display just fine in Outlook…

We found and fix the problem: http://downloads.servoy.com/beta/2.1_product/mail.jar

This really looks pretty good, now! Great job guys!

But life would be boring if there were no further challenges, right? So I have some remarks/questions about the current release:

  1. Could we have a method to retrieve a unique message ID? I need this to be able to check if I already have a message…
  2. Could we have access to ccAddresses?
  3. I don’t get along with the option to retrieve messages of a certain date. If I pass something like var today = new Date() I get an exception. How has that date to be formatted?
  4. I really would appreciate if we had an option to just retrieve all message IDs first and then a possibility to retrieve a single message by ID. It still takes quite a while to retrieve all headers if you have 100 messages on the server…

Otherwise this is perfect!!

  1. there is No messgeID, use the sent date
  2. they are included in the recievers
  3. if recieving the headers only ,use getSentDate() from a particular msg and use that date object to recieve that that message
  4. hmm, headers does have nothing more than subject and some fields , see 1

I tried what you suggested and get a java.lang.classCastException when using a date to retrieve a specific message.

What I do is this:

	var headers = plugins.mail.recieveMail(userName, userPass, true , 1 , null, hostname);
	if (headers)
	{
		for ( var k = 0 ; k < headers.length ; k++ )
		{
			var header = headers[k];
			globals.email_message_date = header.getSentDate();
			if (g_email_message_date_to_kontakte_emails.getSize() == 0) // check to see if message is already there
			{
				var msg = plugins.mail.recieveMail(userName, userPass, true , 0 , header.getSentDate(), hostname); 
				controller.newRecord();
				// save message
			}
		}
	}

As far as number 2. (CC addresses) is concerned: we have quite a bit of business in the financial sector. These guys are pretty serious about everything written. They would not appreciate to not see a difference between a TO address and a CC address. Is that difficult to implement?

Thanks!

http://downloads.servoy.com/beta/2.1_product/mail.jar

Has now getCCaddresses and getCCAddresses() and getRecipientAddresses() does not longer the CC addresses