Link to home
Start Free TrialLog in
Avatar of dirkil2
dirkil2

asked on

Delphi: How can I read mails from an Outlook folder and save them as .txt files

I need to iterate over all mails in a folder in Outlook and extract the text of the emails for further processing. The solution doesn't have to be pretty; just a pragmatic way for accessing the text of the mails would suffice.

I tried the approach with an ADO Connection. This works fine for iterating over the mails. I can read the subject, length, recipient and other data but I don't know how to get the text of the mail itself. It seems that I have to cast the content to some object but I have no idea what object. If you know how to do that would also be enough for me.

Many thanks in advance.

Regards,

Dirk.
Avatar of Luis Pérez
Luis Pérez
Flag of Spain image

I don't know how you're accessing the Outlook items via ADO.net, but have you tried the "Body" property to get the text of the e-mail?
ASKER CERTIFIED SOLUTION
Avatar of Geert G
Geert G
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
dfm
object frmSapAlerter: TfrmSapAlerter
  Left = 365
  Top = 206
  Caption = 'Sap Alert SMS sender [DO NOT CLOSE APPLICATION !]'
  ClientHeight = 451
  ClientWidth = 590
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  OnShow = FormShow
  PixelsPerInch = 96
  TextHeight = 13
  object memInfo: TMemo
    Left = 0
    Top = 65
    Width = 590
    Height = 386
    Align = alClient
    ScrollBars = ssBoth
    TabOrder = 0
  end
  object pnlOptions: TPanel
    Left = 0
    Top = 0
    Width = 590
    Height = 65
    Align = alTop
    BevelOuter = bvNone
    TabOrder = 1
    object btnStart: TBitBtn
      Left = 7
      Top = 5
      Width = 75
      Height = 57
      Caption = 'Start'
      DoubleBuffered = True
      ParentDoubleBuffered = False
      TabOrder = 0
      OnClick = btnStartClick
    end
    object btnStop: TBitBtn
      Left = 103
      Top = 5
      Width = 75
      Height = 57
      Caption = 'Stop'
      DoubleBuffered = True
      ParentDoubleBuffered = False
      TabOrder = 1
      OnClick = btnStopClick
    end
    object btnRunNow: TBitBtn
      Left = 207
      Top = 5
      Width = 75
      Height = 57
      Caption = 'Run now'
      DoubleBuffered = True
      ParentDoubleBuffered = False
      TabOrder = 2
      OnClick = btnRunNowClick
    end
    object btnConfig: TBitBtn
      Left = 311
      Top = 5
      Width = 75
      Height = 57
      Caption = 'Config'
      DoubleBuffered = True
      ParentDoubleBuffered = False
      TabOrder = 3
    end
    object chkTest: TCheckBox
      Left = 408
      Top = 16
      Width = 97
      Height = 17
      Caption = 'Testing'
      Checked = True
      State = cbChecked
      TabOrder = 4
    end
  end
  object outlook: TOutlookApplication
    AutoConnect = False
    ConnectKind = ckRunningOrNew
    AutoQuit = False
    Left = 400
    Top = 32
  end
  object timerCheck: TTimer
    Interval = 600000
    OnTimer = timerCheckTimer
    Left = 336
    Top = 32
  end
  object timerStart: TTimer
    Enabled = False
    Interval = 5000
    OnTimer = timerStartTimer
    Left = 280
    Top = 104
  end
end

Open in new window

Avatar of dirkil2
dirkil2

ASKER

Thanks for the asnwer. I haven't had time to check it. I will do that soon.
Avatar of dirkil2

ASKER

Thank you for your good answer.