Using MailParser

copiloto

Member
Licensed User
Longtime User
Hi everyone,

Could someone guide me adjusting Gmail parameters? I'm trying to use MailParser library without success...

I'm trying: (incoming server)

pop.Initialize("pop.gmail.com", 995, username without .com, mypassword, "pop")

Best regards!.
 

caccas

Member
Licensed User
Longtime User
Hi everyone,

Could someone guide me adjusting Gmail parameters? I'm trying to use MailParser library without success...

I'm trying: (incoming server)

pop.Initialize("pop.gmail.com", 995, username without .com, mypassword, "pop")

Best regards!.

Hi copiloto,

Look this,

To pop:
pop.Initialize("pop.gmail.com", 995, "xxxx@gmail.com", "passwd", "pop")
pop.UseSSL=True


To smtp:
SMTP.Initialize("smtp.gmail.com", 465, "xxxx@gmail.com", "passwd", "smtp")
SMTP.UseSSL=True

bye
 
Upvote 0

copiloto

Member
Licensed User
Longtime User
Hi NJDude and caccas,

Thanks very much for your responses.

I've been running Erel MailParser example,

http://www.basic4ppc.com/forum/basi...p3-communicate-android-devices.html#post63207

changing several configurations and always get the same exception:

An Error has occurred in sub:
main_pop_listcompleted(java line: 286)
java.util.concurrent
RejectedExecutionException:
pool=20/20, queue=0/0
Continue?

Perhaps it could be a partial solution deleting:
Log(LastException.Message)
...
It seems that the app is trying to download more messages?

I have to say that I have only added your line to Erel project:
pop.UseSSL=True


My purpose is to create a service which could catch when a new message has been received and extract the body for example, but, for now, I'll be satisfied if there were no errors...

A little help please..:sign0085:

Best regards!
 
Upvote 0

copiloto

Member
Licensed User
Longtime User
Hi Erel,

Could you drive me how to do it? (I'm running your original example and it's impossible to avoid the exception) It seems that in your app, (from code) the messages are downloaded from the server one after another, not all at the same time? :confused:


Thanks again.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Mails are always downloaded one after another (this is how this protocol works). However you should also submit the requests one after another (when the previous one completes).

I guess that you are calling ListMessages and then downloading all the messages.

You should instead store the Map returned from ListMessages as a process global variable together with an index variable. Now start to download the messages one after another. Each time when a message is downloaded advance the index by one and download the next one until index = Map.Size.
 
Upvote 0

copiloto

Member
Licensed User
Longtime User
Thanks Erel!

I'll try your indications.

Best regards! if get finished my little project I'll upload it,
 
Upvote 0

Hodi

Member
Licensed User
Longtime User
Hi Erel,


I´ve the same problem and I tried your solution but I doesn´t get it to work.
Please can you give me a small example?:confused:

"You should instead store the Map returned from ListMessages as a process global variable together with an index variable. Now start to download the messages one after another. Each time when a message is downloaded advance the index by one and download the next one until index = Map.Size."


Thanks in advance Hodi
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Here (I didn't test this code...):
B4X:
Sub Process_Globals
   Dim pop As POP3
   Dim GlobalMessages As Map
   Dim currentMessage As Int
End Sub
Sub Globals

End Sub
Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
      pop.Initialize("pop.gmail.com", 995, "xxx", "xxx", "pop")
      pop.UseSSL = True
   End If
   pop.ListMessages
End Sub

Sub POP_ListCompleted (Success As Boolean, Messages As Map)
   If Success = False Then
      Log(LastException.Message)
   Else
      Log(Messages.Size)
      GlobalMessages = Messages
      currentMessage = 0
      DownloadMessage
   End If
   pop.Close
End Sub
Sub DownloadMessage
   If currentMessage >= GlobalMessages.Size Then
      Msgbox("All mails were downloaded", "")
      Return
   End If
   pop.DownloadMessage(GlobalMessages.GetKeyAt(currentMessage), False)
   currentMessage = currentMessage + 1
End Sub
Sub POP_DownloadCompleted (Success As Boolean, MessageId As Int, MessageText As String)
   If Success = False Then
      Log(LastException.Message)
   Else
      Log(MessageId)
      'Parse the mail
      Dim M As Message
      M = MailParser.ParseMail(MessageText, File.DirRootExternal)
      Log(M)
   End If
   DownloadMessage
End Sub
 
Upvote 0

Hodi

Member
Licensed User
Longtime User
Hi Erel,

Thank you very much - Now I found the failure in my code!

Thanks for your great support!
Hodi
 
Upvote 0

juancarloscm

Member
Licensed User
Longtime User
Permission denied

Hi, I'm using the example of smtp for sending messages ... but I get the following error

thanks

libcore.io.ErrnoException: open failed: EACCES (Permission denied)

ub Activity_Create(FirstTime As Boolean)
If FirstTime Then
SMTP.Initialize("smtp.gmail.com", 465, "jccortesm79@gmail.com", "XXXXXX", "smtp")
SMTP.UseSSL = True 'Gmail requires SSL.
End If
SMTP.To.Add("jccortesm@saludcoop.coop")
SMTP.Subject = "asunto"
SMTP.Body = "cuerpo del mensaje"
SMTP.AddAttachment(File.DirRootExternal, "somefile")
SMTP.Send
End Sub
Sub SMTP_MessageSent(Success As Boolean)
Log(Success)
If Success Then
ToastMessageShow("Message sent successfully", True)
Else
ToastMessageShow("Error sending message", True)
Log(LastException.Message)
End If
End Sub
 
Upvote 0
Top