• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Attachment Element

 
Brian Podolny
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been tasked with writing a java mailer / webservice to simplify sending emails from within our applications.
The mailer will have a function, sendMail() which will take an xml document as a String parameter. The xml document will contain all of the message info (i.e. sender, recips, message body, etc).
I'm stumped on what would be the best way to include any attachments within the mail doc. Any idea's?
Here are my thoughts:
I'm thinking I will include an <attachmentlist> element which will contain 1 <attachment> element for each attachment for the email. However, I don't know how to write a file as the data for an element and I don't know how I will extract that data and put it into a multipart message.
Thanks!
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you decided to use webservice
My idea could be to convert the file in to a byte array (base64Binary) as one element and file extension as one element.
The server will convert the byte array into a file with the given file extension and send it as an attachement to the user.
But you have to decide whether you need a webservice to do this task according to your requirements
 
Brian Podolny
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that will work. I might include the file extension as an attribute of the attachment element rather than as a separate element. I could probably include the encoding type as an attribute as well - to increase flexibility. What do youy think?
The main point of the mailer as a webservice is for applications to have a simple and common way to send notification messages. File attachments will rarely be used but I think I need to plan for them. Unfortunately, forcing the developer to encode attachments and then embed them into an xml doc in order to use the webservice, doesn't really simplify things for the developer at all.
Thanks again!
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Brian Podolny:
Unfortunately, forcing the developer to encode attachments and then embed them into an xml doc in order to use the webservice, doesn't really simplify things for the developer at all.
Thanks again!

Well!..
In that case you can supply a sample code fragement for both java/microsoft clients, or a sort of small tutorial may also attract them.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic