>  I am using Delphi 7 and learning the 
> component "OverbyteIcsMimeDemo", I am writing a program to read my 
> messages and save them as text files and save any attachments as 
> separate files.  I seem to have grasped the export of text data 
> however any attempt at save the attachments fails and I simply do 
> not understand
>  how to for example identify a pdf attachment and save it to disk 
> or in fact any attachment.

Run OverbyteIcsMimeDemo, specify mime-demo3.txt and click 'Decode File
Extended'.  This will decode all MIME parts and load them into an array
MimeDecodeEx.PartInfos, with one record for each part, reported similarly
to this (edited):
Part 6, Content: image/jpeg, Size: 4902, Name: wt_logo_210x47.jpg,
FileName: , Encoding: base64, Charset: , ApplType: , Content Id:
Part 7, Content: image/gif, Size: 4979, Name: Watch-the-film1.gif,
FileName: , Encoding: base64, Charset: , ApplType: , Content Id:
Part 10, Content: application/vnd.ms-excel, Size: 75776, Name: D10.xls,
FileName: D10.xls, Encoding: base64, Charset: , ApplType: vnd.ms-excel,
Content Id: 

Your application needs to loop through the different PartInfos records in
the array, similarly to DecodeFileExButtonClick, checking PContentType
which contains the MIME type for each attachment, ie image/jpeg,
application/vnd.ms-excel or application/pdf for Acrobat files.  Sometimes
the PName and/or PFileName will have a complete file name with file
extension, sometimes they will be blank. 

You can use the function ContentTypeGetExtn to get the Windows defined
file extension for any MIME type if you want to build your own file name.

I guess the one thing missing from the demo is how to save the content,
which is patiently waiting in PartStream, so use the SaveToFile method: 

  MimeDecodeEx.PartInfos [I].PartStream.SaveToFile (fname) ;
  Log('!! Failed to Save Attachment) ;
end ;

Note the V8 OverbyteIcsMimeDemo dfm file seems to have got corrupted and
is missing several new buttons added to test TMimeTypesList, I'll fix it
later today. 


To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to