Returns part of the content as Java object. The type of this object depends of the content itself. For example, the native format of an content "text/plain" is normally an object String. The native format for a message "multipart" is always a subclass Multipart.
For type of contents which are unknown for the DataHandler system, an input stream is returned as the content.
1 mail.mimePart.getContent
<mail.mimePart.getContent>
<MimeMessage /> +
</mail.mimePart.getContent>
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
EMimeMessage | MimeMessage |
Returns | |
---|---|
Type | Description |
Object |
Example
Obtain the content of a mimePart.
Copy
<xsql-script name=''> <body> <select prefix='m_'> <columns>mail_message</columns> <from table='wic_user_maildata ' /> <where> uid = 1949240 </where> </select> <set name='m_mimeMessage'> <mail.mimeMessage> <m_mail_message /> </mail.mimeMessage> </set> <set name='m_mail_parts_array'> <mail.mimePart.getParts><m_mimeMessage /></mail.mimePart.getParts> </set> <iterator name='part' index='idx'> <in><m_mail_parts_array /></in> <do> <println> <mail.mimePart.getContent><part /></mail.mimePart.getContent> </println> </do> </iterator> </body> </xsql-script>
Example
Obtain the content of an attachment of a mimePart and store it in disk.
Copy
<xsql-script name=''> <body> <-- SELECT THE BLOB --> <select prefix='m_'> <columns>mail_message</columns> <from table='wic_user_maildata ' /> <where> uid = 2949240 </where> </select> <!-- MESSAGE OBJECT --> <set name='m_mimeMessage'> <mail.mimeMessage> <m_mail_message /> </mail.mimeMessage> </set> <!-- Array with the parts of the message--> <set name='m_mail_parts_array'> <mail.mimePart.getParts><m_mimeMessage /></mail.mimePart.getParts> </set> <iterator name='item' index='idx'> <in><m_mail_parts_array /></in> <do> <!-- FILE NAME --> <set name='fname'><mail.mimePart.getFileName><item /></mail.mimePart.getFileName></set> <!-- FILE DESTINATION PATH --> <set name='m_file'> <string>c:<file.separator />tmp<file.separator /><fname /></string> </set> <!-- If it is an attachment, store it in a file --> <if> <expr><eq><mail.mimePart.getDisposition><item /></mail.mimePart.getDisposition><string>attachment</string></eq></expr> <then> <file.bytes.write> <file name='#m_file' type='absolute' /> <datahandler.getBytes> <object.2dataHandler> <mail.mimePart.getContent><item /></mail.mimePart.getContent> </object.2dataHandler> </datahandler.getBytes> </file.bytes.write> </then> </if> </do> </iterator> </body> </xsql-script>