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.


I prepeared a small demo application where I included all described tips for MS Outlook programming. You can download this project with sources: (150Kb)

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

Published: August 14, 2001

See also
ABA Database Convert
Clarion Viewer
Paradox Viewer
Fast Document Viewer
SMImport suite
Clarion to Text converter
ABA Spreadsheet Convert
Paradox ActiveX

Contact to webmaster


Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2021, Scalabium Software. All rights reserved.

SMExport advertising