Attachment handling is desribed in the documentation. The body of the attachment is base64 encoded on the wire. You posted in General Development and diWdn't bother to indicate what programming language you are using, so you won't get much detail.
What do you mean by custom application? Throw us a bone here.
What do you mean by custom application? Throw us a bone here.