Scalabium Software

SMExport advertising
Knowledge for your independence'.
Home Delphi and C++Builder tips


#123: How can I retrieve and save the attachments from MS Outlook message?

I want to continue the postings about MS Outlook programming in Borland Delphi.
Today I want to show how you can recieve a list of files in attachment for any message and save some from these attachments to disk:

Each message have the Attachments collection which contains a list of files. As usual collection, the Attachments property have the Count property where you can read a number of files and access to each file using Item method.

For example, in code below you'll see how to add in TListView component the rows for each attachment file:

for i := 1 to itemOL.Attachments.Count do
  with lvAttachments.Items.Add do
    Caption := itemOL.Attachments.Item(i);

Of course, don't forget that VB's collection have the 1 as starting index.

Also each item in Attachments collection have the SaveAsFile method which allow to save an attachment into file on disk. The parameter of SaveAsFile is a desired file name.

itemOL.Attachments.Item(i).SaveAsFile(itemOL.Attachments.Item(i));

I prepeared a small demo application where I included all described tips for MS Outlook programming. You can download this project with sources: http://www.scalabium.com/faq/delphioutlook.zip (150Kb)

PS: if you'll have some questions or suggestions, please contact me


Published: August 14, 2001

See also
 
SMExport suite
Excel Web-stream
ABA Document Convert
DBExport tools
ABA Spreadsheet Convert
Mail parser (ActiveX)
ABA Database Convert
Metafile Convert
SMReport
Paradox to Text converter
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2025, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMReport Autogenerated