How to send mail with EXCEL as attachment

Recently I just complet a module for generating an format excel and send it to user as attachment. The solution I choose is:

  1. Generating an excel file in local server,and write data to the file.
  2. Read the file from local and transfer it to binary
  3. send the xls file to user with pub.client:smtp.

    As design, there is no need to generate a real file in local server but only generate it in binary. However, I don’t know how to do like this. if anyone have the idea, I appraciated for your point out.

Now I will show you the parameter setting when sending the Excel file with the methods:pub.client:smtp
[ATTACH=CONFIG]848[/ATTACH]
contenttype: application/vnd.ms-excel
filename: report.xls
encoding: base64
charset: utf-8

The following is the contenttype list for your reference:
[URL]http://webdesign.about.com/od/multimedia/a/mime-types-by-content-type.htm[/URL]
smtp.jpg