Information générale
Catégorie:
Programmation Orientée Object
Titre:
General field export
When selecting attachments (BLOB'S) stored in an backend table, I retrieve it as a general field for mailing as an attachment. In order to do this I was copying the general field to a separate table and then changing the file type to 'Memo' and then doing a low level file write to create an attachment file. (IF anyone's got a better way I'd love to hear it, I based this on a FAQ that I saw on UT). However, sometimes the file is a spreadsheet, sometimes a BMP. Any ideas on how to then get it in the proper format so that when the recipient opens it the proper association is made? I had a excel spreadsheet stored and wrote it to a filename.xls. The association seemed correct but when it opened it was basically gibberish. Any help would be greatly appreciated. See code snippet below:
tcf='tcf_'+sys(3)
select attach_fle from sendmail into cursor tempfile
if file(tcf+".dbf")
erase (tcf+".dbf")
endif
if file(tcf+".fpt")
erase (tcf+".fpt")
endif
copy to (tcf)
use in select('tempfile')
* change general field type to memo
ll = fopen(tcf+".dbf",12)
fseek(ll,43)
fwrite(ll,'M')
fclose(ll)
* save data from memo field into file
use (tcf) alias TT
this.FileName = getenv('temp')+'\'+"tempfile.xls" && what if it was a BMP?
if file(this.FileName)
erase (this.FileName)
endif
local lH
lH = FCREATE(this.fileName)
FWRITE(lH,TT.attach_fle)
FCLOSE(lH)
* Clean up files
use in select('TT')
use in select(tcf)
if file(tcf+".dbf")
erase (tcf+".dbf")
endif
if file(tcf+".fpt")
erase (tcf+".fpt")
endif
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement