I have moved the attachment code into the post.