VS2008/C# 3.0 (.NET 3.5)
GW POA 8.0.1

My app duplicates certain messages from a user account by copying them to a
proxy account using a call to createItemRequest() (i.e. a mail message is
added to a folder in a proxy account without the item being "sent".)

In order to duplicate the message completely, the original message's
attachments are added to the duplicate message. This is done by streaming
the attachments from the original message to disk, then attaching them to
the duplicate message from disk. The "attachments" collection for the
duplicate message is populated with the attachment file data from disk.

According to the documentation, Mail.attachments[x].data (i.e. the
AttachmentItemInfo.data element) should be base64-encoded

// NOTE: sourceMessage.attachments have been saved to disk.
// A global Dictionary<String, String> object exists that
// hashes the original attachment item ID to it's path
// on the local disk. The Dictionary object is named
// "m_attachmentPaths". A path is accessed by using an
// id as an index into the Dictionary.
public Mail CloneMessage(Mail sourceMessage)

Mail copyMessage = new Mail();

copyMessage.distribution = sourceMessage.distribution;
copyMessage.internet = sourceMessage.internet;
copyMessage.internetSpecified = sourceMessage.internetSpecified;
copyMessage.message = sourceMessage.message;
copyMessage.options = sourceMessage.options;
copyMessage.originalSubject = sourceMessage.originalSubject;
copyMessage.security = sourceMessage.security;
copyMessage.securitySpecified = sourceMessage.securitySpecified;
copyMessage.source = sourceMessage.source;
copyMessage.sourceSpecified = sourceMessage.sourceSpecified;
copyMessage.status = sourceMessage.status;
copyMessage.subject = sourceMessage.subject;
copyMessage.subType = sourceMessage.subType;
copyMessage.xField = sourceMessage.xField;

// handle attachments
copyMessage.attachments = sourceMessage.attachments;

foreach (AttachmentItemInfo aii in copyMessages.attachments)
if (m_attachmentPaths.containsKey(aii.id.Value) // should be
true for every attachment.
// get the file path.

String attPath = m_attachmentPaths[aii.id.Value];

// convert file contents to base64 string.

byte[] fileContents = File.ReadAllBytes(attPath);
String encodedFileContents =

// convert base64 string to byte array and
// store in AttachmentItemInfo object.

System.Text.ASCIIEncoding encoding = new
aii.data = encoding.GetBytes(encodedFileContents);

} // end of foreach loop

return copyMessage;

} // end of method.

The duplicate message is later modified by setting its "container" element
value to the id of the folder it will be created in. It is then used in a
call to createItemRequest() to create the message in the target folder
(which seems to work just fine.)

Note that AttachmentItemInfo.data is a byte array. So, I have to take the
raw contents of the file, create a base64-encoded string from it, then
convert the string to a byte array and store it in AttachmentItemInfo.data.

However, when I do this, the attachment in the duplicate message simply
contains base64-encoded data. My expectation is that the encoding only
persists during the transfer of the SOAP message, and that the
AttachmentItemInfo.data element would be base64-decoded by the POA before
the attachment was actually added to the duplicate message in the target
message store.

If I add the *raw* file content to AttachmentItemInfo.data, without encoding
it, it seems to work correctly.

Is this a bug in the API, or in the documentation?