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.
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
ASKER
Thanks for the asnwer. I haven't had time to check it. I will do that soon.
ASKER
Thank you for your good answer.