You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

On this Page:
To receive and delete mails from a POP3-Server, you can use the POP3-Adapter. The POP3 parameters can be set statically or dynamically.

Example File (Builder project Add-ons/EMail):

<your example path>\Add-ons\EMail\uml\pop3.xml

Receive Mails (Static Usage)

In order to receive a mail from the POP3-Server, the action getMessage   is applied in the POP3-Adapter. In the static usage, the POP3-Parameters are provided from the configuration and deployment diagram by the alias tagged-value on the POP3-Adapter.

Figure: Static Usage of the POP3 Adapter

As illustrated by the Figure Static Usage of the POP3 Adapter has an input parameter deleteOnServer. The parameter is of type Boolean and indicates, whether the message is to be deleted after it has been fetched by the POP3 adapter. If the parameter is set to true, a DELE command is send to the POP3-Server and the message will be flagged as to be delete. When the whole SOAP request (i.e. not only the activity where the POP3 adapter is modelled) has come to an end without an exception, the POP3 session will be closed with a QUIT command and the POP3-Server deletes the messages definitely.

But if there is an exception during the whole processing, the POP3 session will be closed with a RSET command and all marks are removed on the messages, this means no message will be deleted.  

The parameter deleteOnServer can not be specified in the component diagram, even in the case of a static usage it has to be modelled as a dynamic parameter.

If there is more than one message in your server's inbox and you want to fetch all of them, you have to do it one after another in a separate getMessage call. The POP3 adapter does not retrieve all messages at one time and store them in an array. As illustrated in the example, the output of the adapter is a single message object. To get another message from the mail server you have to draw the control flow back to the POP3 adapter and start another getMessage call.

The output parameter is message. The whole content of the message is stored as a Blob in the attribute content (refer in the containment tree to Data - Base Components - Add Ons - POP3 - POP3Message). Hence, the content must be decoded and separated into parts. This is done by the MIMEConverter in the sub activity extractMessage (for details refer to the chapter MIME Converter ).

Figure: Decode MIME-Parts

Sometimes it is necessary do access the POP3-Headers as in action build out message. The attribute pop3Header of class POP3Message holds the raw POP3 headers.

Receive Mails (Dynamic Usage)

Figure: Dynamic Usage of the POP3 Adapter

Unlike the static usage of the POP3 adapter, all input parameters of the adapter are passed on to it during runtime in the dynamic case (as illustrated in the above figure).

Delete and  Commit/Rollback Received Mails

Instead of to set the deleteOnServer flag at the same time when receiving the mail, you can send a delete command later in your processing as well. For that purpose, use the POP3-Adapter with the action delete with input message  of type POP3messsage and sessionID of type String which are both received previously with the getMessage action.

Figure: Delete, commit, rollback on the POP3Servers

As already mentioned before, the messages on the POP3-Server are deleted after the SOAP-request (transaction) has ended without an exception if the deleteOnServer flag is set. But when processing a large amount of messages or in other circumstances it might be necessary to commit or rollback the deletion of the message on the POP3-Server manually.

In order to do this, use the POP3-Adapter with the action commit respectively rollback. As input the sessionId is used only, which was received with the getMessage action before.

  • No labels