Mail plugin with pop3 support

Release notes for Servoy betas

Postby Jan Blok » Wed Sep 08, 2004 12:50 am

patrick wrote: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
Jan Blok
Servoy
Jan Blok
 
Posts: 2684
Joined: Mon Jun 23, 2003 11:15 am
Location: Amsterdam

Postby patrick » Fri Sep 10, 2004 12:18 pm

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!!
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Postby Jan Blok » Fri Sep 10, 2004 1:27 pm

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
Jan Blok
Servoy
Jan Blok
 
Posts: 2684
Joined: Mon Jun 23, 2003 11:15 am
Location: Amsterdam

Postby patrick » Fri Sep 10, 2004 5:33 pm

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:

Code: Select all
   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!
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Postby Jan Blok » Fri Sep 17, 2004 3:32 pm

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

Has now getCCaddresses and getCCAddresses() and getRecipientAddresses() does not longer the CC addresses
Jan Blok
Servoy
Jan Blok
 
Posts: 2684
Joined: Mon Jun 23, 2003 11:15 am
Location: Amsterdam

Postby patrick » Fri Sep 17, 2004 3:43 pm

Thanks! :lol:

I will test that in a minute. How about that java.lang.classCastException that I get when passing header.getSentDate()?
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Postby Jan Blok » Fri Sep 17, 2004 4:00 pm

I forgot to ask, could you sent me the .log.txt when this happens?
Jan Blok
Servoy
Jan Blok
 
Posts: 2684
Joined: Mon Jun 23, 2003 11:15 am
Location: Amsterdam

Postby patrick » Fri Sep 17, 2004 5:51 pm

Now I always get "null" when I do

Code: Select all
var headers = plugins.mail.recieveMail(userName, userPass, true , 1 , null, hostname);


??
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Postby patrick » Fri Sep 17, 2004 5:52 pm

and the log says

java.lang.NullPointerExceptionjava.lang.NullPointerException
at com.servoy.r2.plugins.mail.MailServerUtils.createAddressString(MailServerUtils.java:133)
at com.servoy.r2.plugins.mail.MailServerUtils.createMailMessage(MailServerUtils.java:38)
at com.servoy.r2.plugins.mail.MailServer.recieveMail(MailServer.java:213)
at com.servoy.r2.plugins.mail.MailProvider.js_recieveMail(MailProvider.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:289)
at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1237)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:1940)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:94)
at com.servoy.j2db.scripting.e.call(Unknown Source)
at com.servoy.j2db.develop.debugger.n.a(Unknown Source)
at com.servoy.j2db.develop.debugger.n.access$14(Unknown Source)
at com.servoy.j2db.develop.debugger.n$3.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Postby grahamg » Tue Sep 21, 2004 11:46 am

Hi Jan

Downloaded latest version of Mail Plugin - your post 17 Sep 1.32pm - but cannot get started.

Trying to test by downloading first few messages but after a short delay [msgs] always returns null.

---------------------------------------

//Recieve mails from pop3 account
var msgs = plugins.mail.recieveMail('ztvo0afzzzzz', 'WnKN2rB7Xzzzzz', true);
if (msgs != null) //if is null error occurred!
{
// for (var i = 0 ; i < msgs.length ; i++)
for (var i = 0 ; i <=6 ; i++)
{
var msg = msgs[i]


------------------------------------------

Have tried with two different mail accounts/providers.
grahamg
 
Posts: 752
Joined: Fri Oct 03, 2003 3:15 pm
Location: Midlands UK

Postby Harry Catharell » Tue Sep 21, 2004 1:15 pm

Servoy Developer
Version R2 2.1-build 310
Java version 1.4.2-38 (Mac OS X)

I am getting inconsistent results, too.

I am using office accounts where I know that mails are waiting for collection to test.

I can get mail from one account but not the other five that I have tried.

I have 'null' returned for 'msgs' in those instances.

I have used the sample code which does work fine on the account which responds and which shows the output correctly as I step through the method !

Cheers
Harry
Harry Catharell
 
Posts: 812
Joined: Fri Sep 26, 2003 10:23 am
Location: Milton Keynes, England

Postby grahamg » Tue Sep 21, 2004 2:41 pm

Sorry should have included:

Servoy Developer
Version R2 2.1-build 310
Java version 1.4.1_03-b02 (Windows XP)

Like Harry I am checking accounts where I know there are plenty of messages although they will have been read by Outlook - does this set a flag that's triggering the 'null' return??

GrahamG
grahamg
 
Posts: 752
Joined: Fri Oct 03, 2003 3:15 pm
Location: Midlands UK

Postby Harry Catharell » Tue Sep 21, 2004 3:24 pm

I know that the messages that I can see have NOT been read.

I have sent the messages to the target accounts myself and attempted to read them with the mail PlugIn before the mail clients have accessed them !

Also the mail clients of target test accounts are set to delete the messages from the server once downloaded - so the messages up there should be virgin messages anyway !

'Curiouser and curiouser', said Alice !

Harry
Harry Catharell
 
Posts: 812
Joined: Fri Sep 26, 2003 10:23 am
Location: Milton Keynes, England

Postby Jan Blok » Wed Sep 22, 2004 12:42 pm

patrick wrote:Now I always get "null" when I do


It seems the cc header is not present at all when empty on some mailserver, fixed: http://downloads.servoy.com/beta/2.1_product/mail.jar
Jan Blok
Servoy
Jan Blok
 
Posts: 2684
Joined: Mon Jun 23, 2003 11:15 am
Location: Amsterdam

Postby Harjo » Sun Sep 26, 2004 7:58 pm

I have a few questions about the pop3 plugin:

1.) I have a method that only downloads the headers. That is working fine.
Now i have the following method, that must only download the current mail:
Code: Select all
var recieveMode = 1;//0=FULL,1=HEADERS_ONLY,2=NO_ATTACHMENTS
var msgs = plugins.mail.recieveMail(p_username, p_password, true,recieveMode, senddate);

senddate is a column with the Senddate in it.

But I'll get the following error:
Code: Select all
java.lang.ArrayIndexOutOfBoundsException

What am I doing wrong?

2.) When I do this: (sample code)
Code: Select all
var attachments = msg.getAttachments()
if (attachments != null)
{
   for (var j = 0 ; j < attachments.length ; j++)
   {
      var attachment = attachments[j]
      //application.output(attachment.getName())
      var attachmentDataByteArray = attachment.getData()
      //write attachmentDataByteArray to a file...
   }
}

Does that mean, that when I do this in a client, that an attachment of about 4MB, is first downloaded to (the client) variable: attachments and if I put it in the database, is the whole 4mb uploaded again??

3. In (for example) Outlook there is a function, that you can keep messages on the server for let's say: 20 days.
Is this standard email-functionality, or is it something that only Outlook does?

4. Jan, you said that there was no unique emailnumber. In almost all the pop3 beans you find something like this:
elements.bean_680.getMessageUID(number) or
elements.bean_680.getNoOfMessage()
Now we have to download always all the headers, to determe how many emails there are, en determe which emails must be downloaded.
If there are 20 message, this is not a problem, but if there are 100, this is a problem.
A customer of us is using pop3/imap server. The imap-server is reachable by a webbrowser too. So if we do a pop3 session, we must leave the message on the server, because else the message would not be seen in the (imap) webbrowser.

Is there an easier (less overhead) way to do this?

5.) In the debugger I see also function, like: notify and notifyAll
What does that do?

6.) Why is the getReceivedDate() always empty?? (returning null)
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

PreviousNext

Return to Latest Releases

Who is online

Users browsing this forum: No registered users and 16 guests