1.11 Message Bodies

Message bodies can be in the following formats:

The following sections describe how to deal with large message bodies and HTML message bodies.

1.11.1 Large Message Bodies

To retrieve message bodies, the message keyword should be included in the view. For message bodies smaller than 32 KB, the message body is returned in the message element itself. For message bodies greater than 32 KB, a message ID attribute is returned instead of the message body. If a message ID is returned, call getAttachmentRequest to download the message body.

The following example returned a large message body. The ID is an attribute on the message element, and the length of the file is just over 1 MB.

<items> 
   <item type="Mail"> 
      <id>452A4D93.domain1.po1.100.1647535.1.635.1@1:7.
                     domain1.po1.100.0.1.0.1@16</id> 
      ...
      <subject>Large Message Body</subject> 
      <message> 
         <part contentType="text/plain" length="1008596" id="452A4D93.
         domain1.po1.200.20000B2.1.374.1@65:452A4D93.domain1.po1.100.
           1647535.1.635.1@1:7.domain1.po1.100.0.1.0.1@16" /> 
      </message> 
      ...
   </item> 
</items> 

To read the message body, call getAttachmentRequest with the ID of the message body. getAttachmentRequest allows you to read the message body in chunks by providing an offset and a length. The offset is the location in the file to start reading. The length is the number of bytes to read. In the first call to getAttachmentRequest, the offset is 0 and the length is 16 KB.

<getAttachmentRequest> 
   <id>452A4D93.domain1.po1.200.20000B2.1.374.1@65:452A4D93.domain1.
       po1.100.1647535.1.635.1@1:7.domain1.po1.100.0.1.0.1@16</id> 
   <offset>0</offset> 
   <length>16384</length> 
</getAttachmentRequest>

In the following example, the offset is an attribute on the part element. In the next call to getAttachmentRequest, pass in the returned offset value as the offset. The reason the offset can be different than the length passed in is because message bodies are stored in GroupWise in an internal format. After you read in the requested amount of data from the GroupWise store, the data is translated and the size changes.

<getAttachmentResponse > 
   <part length="16180" offset="16379"> 
        Njk3MzcwNkM2MTc5MjA2NDZGNjM3NTZENjU2RTc0NzMyMD
        c5NkY3NTIwNjg2MTc2NjUyMDY
        ...
        EAgRk9MREVSX1JFQ09SRCA=</part> 
      <gwm:status> 
   <code>0</code> 
   </status> 
</getAttachmentResponse>

The next time getAttachmentRequest is called, it looks like the following example. The offset on the call matches the offset returned in the last getAttachmentResponse.

<getAttachmentRequest> 
   <id>452A4D93.domain1.po1.200.20000B2.1.374.1@65:452A4D93.
   domain1.po1.100.1647535.1.635.1@1:7.domain1.po1.100.0.1.0.1@16</id> 
   <offset>16379</offset> 
   <length>16384</length> 
</getAttachmentRequest>

The example above is only for message bodies. Normal attachments return the same offset as the specified length.

1.11.2 HTML Message Bodies

Message bodies can be in HTML format. HTML messages are returned as the first attachment and are named text.htm. Any embedded images or associated files are also downloaded as attachments. These HTML associated files are all marked hidden.

The HTML message body and accompanying files are grouped together. The text.htm file is first, followed by the other associated files. Each of the accompanying attachments has a contendId element. Loop through the attachments until you come to an attachment that does not have a contentId element or until you come to the end of the attachments. If you want to create an HTML message body in SOAP, you need to add the attachments in the same order and add the contentId element for the accompanying files.

In the following example, an item has an HTML message body with an embedded image. The attachments section contains a text.htm file. Attachment 2 is an embedded image in the HTML attachment. Also notice that the message element itself has a message body. This is the attachment in plain/text format.


<item type="Mail"> 
   <id>452A6054.domain1.po1.100.1647535.1.644.1@1:7.
           domain1.po1.100.0.1.0.1@16</id> 
   ...
   <message> 
      <part contentType="text/plain"             
       length="284">e1xydGYxXGRlZmYwe1xmb250dGJse1xmMFxmbmlsXGZj
       aGFyc2V0MSBUYWhvbWE7fX17XGNvbG9ydGJsO1xyZWQyNTVcZ3JlZW4wX
       GJsdWUwO1xyZWQyNTVcZ3JlZW4wXGJsdWUwO317XHN0eWxlc2hlZXR7XGZz
       MTYgR3JvdXBXaXNlVmlldzt9fVxmczE2IEhUTUwgbWVzc2FnZSB3aXRoIGF
       uIGltYWdlLlxwYXIgIFxwYXIgIFxwYXIgQWZ0ZXIgdGhlIHBpY3R1
       cmUuXHBhciB9</part> 
   </message> 
   <attachments> 
      <attachment> 
         <id>452A6054.domain1.po1.200.20000B2.1.398.1@45:452A6054.
                domain1.po1.100.1647535.1.644.1@1:7.domain1.po1.
                100.0.1.0.1@16</id> 
         <name>Text.htm</name> 
         <contentType>TEXT/HTML</contentType> 
         <size>409</size> 
         <date>2012-10-09T14:44:35Z</date> 
         <hidden>1</hidden> 
      </attachment> 
      <attachment> 
         <id>452A6054.domain1.po1.200.20000B2.1.399.1@45:452A6054.
               domain1.po1.100.1647535.1.644.1@1:7.domain1.po1.
               100.0.1.0.1@16</id> 
         <name>IMAGE.gif</name> 
         <contentId><UQSTEWRZPCCH.appt.gif></contentId> 
         <contentType>IMAGE/gif</contentType> 
         <size>143</size> 
         <date>2012-10-09T14:44:35Z</date> 
         <hidden>1</hidden> 
      </attachment> 
   </attachments> 
   ...
</item>

To retrieve the HTML message, call getAttachmentRequest with the ID of the text.htm file. Your method should look similar to the following:

<getAttachmentRequest> 
   <id>452A6054.domain1.po1.200.20000B2.1.398.1@45:452A6054.
         domain1.po1.100.1647535.1.644.1@1:7.domain1.po1.
         100.0.1.0.1@16</id> 
</getAttachmentRequest>

<getAttachmentResponse> 
   <part length="548"
      offset="409">PEhUTUw+PEhFQUQ+DQo8TUVUQSBodHRwLWVxdWl2PUN
      vbnRlbnQtVHlwZSB
      ...
      ERJVj5BZnRlciB0aGUgcGljdHVyZS48L0RJVj48L0JPRFk
     +PC9IVE1MPg==
   </part> 
   <status> 
      <code>0</code> 
   </status> 
</getAttachmentResponse>

The actual HTML message follows. The embedded image below has a src value equal to the contentId of the second attachment in the preceding example.

<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<BODY style="MARGIN: 4px 4px 1px; FONT: 10pt Tahoma">
<DIV>HTML message with an image.</DIV>
<DIV>&nbsp;</DIV>
<DIV><IMG alt="" hspace=0 src="cid:UQSTEWRZPCCH.appt.gif" align=baseline border=0></DIV>
<DIV>&nbsp;</DIV>