Parsing mails

One Star

Parsing mails

Hello,
Do you know how may I parse emails on my server. They all put in a specific folder and I want to parse this kind of mail :
"Bonjour,
Un L24 a été déplacé en erreur suite détection d'une anomalie Merci de prévenir le transporteur

VIN: UU1JSDA0551346737
RAISON  LO24 non intégré - Le lot '110262' n'existe pas"
I can have 50 mails like that and I want to retreive only the value VIN: .....
Do you know if it's possible with the component cMail or tPop ?
Four Stars

Re: Parsing mails

Hi,
- download all mails
- Use tFileInputMail component to read and extract part of mail i.e. Body
- Use regular expression to extract text from the body i.e. VIN: xxxx
Vaibhav
One Star

Re: Parsing mails

Hi,
Thank you for your answer. Do you know how may I download all mails for a specific folder ? not from my main mailbox
Moderator

Re: Parsing mails

Hi,
You can use "Imap" protocol to "Specify Mail Folder" in tPopComponent.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: Parsing mails

Hi,
It doesn't work:
 connecting to socket on port 3665
connected
Exception in component tPOP_1
javax.mail.MessagingException: No login methods supported!;
  nested exception is:
    com.sun.mail.iap.ProtocolException: No login methods supported!
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:477)
    at javax.mail.Service.connect(Service.java:275)
    at javax.mail.Service.connect(Service.java:156)
    at javax.mail.Service.connect(Service.java:105)
    at mail.mail_0_1.Mail.tPOP_1Process(Mail.java:356)
    at mail.mail_0_1.Mail.runJobInTOS(Mail.java:673)
    at mail.mail_0_1.Mail.main(Mail.java:522)
Caused by: com.sun.mail.iap.ProtocolException: No login methods supported!
    at com.sun.mail.imap.IMAPStore.login(IMAPStore.java:519)
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:458)
    ... 6 more
disconnected

Moderator

Re: Parsing mails

Hi,
Have you tried to check out SSL encryption option when you using IMAPS protocol?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: Parsing mails

Hi,
Yes and it doesn't work either Smiley Sad
Démarrage du job Mail a 14:02 20/08/2014.
connecting to socket on port 3692
connected
Exception in component tPOP_1
javax.mail.MessagingException: Unrecognized SSL message, plaintext connection?;
  nested exception is:
    javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:479)
    at javax.mail.Service.connect(Service.java:275)
    at javax.mail.Service.connect(Service.java:156)
    at javax.mail.Service.connect(Service.java:105)
    at mail.mail_0_1.Mail.tPOP_1Process(Mail.java:364)
    at mail.mail_0_1.Mail.runJobInTOS(Mail.java:681)
    at mail.mail_0_1.Mail.main(Mail.java:530)
Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
    at sun.security.ssl.InputRecord.handleUnknownRecord(InputRecord.java:671)
    at sun.security.ssl.InputRecord.read(InputRecord.java:504)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
    at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:882)
    at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)
disconnected
    at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:97)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
    at com.sun.mail.iap.ResponseInputStream.read0(ResponseInputStream.java:81)
    at com.sun.mail.iap.ResponseInputStream.readResponse(ResponseInputStream.java:67)
    at com.sun.mail.iap.Response.<init>(Response.java:83)
    at com.sun.mail.imap.protocol.IMAPResponse.<init>(IMAPResponse.java:48)
    at com.sun.mail.imap.protocol.IMAPResponse.readResponse(IMAPResponse.java:122)
    at com.sun.mail.imap.protocol.IMAPProtocol.readResponse(IMAPProtocol.java:230)
    at com.sun.mail.iap.Protocol.<init>(Protocol.java:91)
    at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:87)
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:446)
    ... 6 more
Job Mail terminé à 14:02 20/08/2014.
Moderator

Re: Parsing mails

Hi,
Is your input parameter correct? SMTP connections secured by are known by the shorthand on TCP port 465. Could you please check your input paramater in tPop component?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Moderator

Re: Parsing mails

Hi rungis,
Is there any update for your issue?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: Parsing mails

Hi,
Is your input parameter correct? SMTP connections secured by are known by the shorthand on TCP port 465. Could you please check your input paramater in tPop component?
Best regards
Sabrina

Hi Sabrina,
I see why it gave rungis an error.
To read mail with IMAP it's port 143.
IMAPS (SSL encrypted) is port 993.
( SMTPS, for sending mail with SSL encryption, is on port 465. )