-
Nov 28th, 2022, 03:15 AM
#1
Thread Starter
Lively Member
Is there any VB6 tools or library for parsing eml files?
-
Nov 28th, 2022, 03:43 AM
#2
Re: Is there any VB6 tools or library for parsing eml files?
You mean as an email saved to disk?
-
Nov 28th, 2022, 03:16 PM
#3
Re: Is there any VB6 tools or library for parsing eml files?
Which "eml" files? Many file extensions get reused by different software for different formats.
CDO for Windows can create and work with one format.
-
Nov 29th, 2022, 03:37 PM
#4
Re: Is there any VB6 tools or library for parsing eml files?
Example:
Code:
Option Explicit
'
'For Windows 2000 or later. Requires a reference to:
'
' Microsoft CDO For Windows Library
' Microsoft ActiveX Data Objects 2.5 Library
' tom (Text Object Model in RICHED20.dll)
'
'RichTextBox1: MultiLine = True, ScrollBars = rtfBoth
'
Private Const WM_USER As Long = &H400&
Private Const EM_GETOLEINTERFACE As Long = WM_USER + 60
Private Declare Function SendMessage Lib "user32" Alias "SendMessageW" ( _
ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Private TextDocument As tom.ITextDocument
Private Sub Dump(ByRef Name As String, ByRef Value As String)
With TextDocument.Selection
.Font.Bold = tomTrue
.Text = Name & vbNewLine
.Move tomParagraph, 1
.Font.Bold = tomFalse
.Para.SetIndents 0, 10, 10
.Text = Value & vbNewLine
.Move tomParagraph, 1
.Para.SetIndents 0, 0, 0
End With
End Sub
Private Sub Form_Load()
Dim IUnknown As stdole.IUnknown
Dim Message As CDO.Message
Dim Stream As ADODB.Stream
SendMessage RichTextBox1.hWnd, EM_GETOLEINTERFACE, 0, VarPtr(IUnknown)
Set TextDocument = IUnknown
Set Message = New CDO.Message
Set Stream = New ADODB.Stream
With Stream
.Open
.LoadFromFile "draft.eml"
.Type = adTypeText
.Charset = "us-ascii"
Message.DataSource.OpenObject Stream, "_Stream"
.Close
End With
'Clear any text present:
With TextDocument.Selection
.Expand tomStory
.Delete tomCharacter, 0
End With
With Message
Dump "From", .From
Dump "To", .To
Dump "Subject", .Subject
Dump "TextBody", .TextBody
Dump "Attachments.Count", CStr(.Attachments.Count)
End With
End Sub
Private Sub Form_Resize()
If WindowState <> vbMinimized Then
RichTextBox1.Move 0, 0, ScaleWidth, ScaleHeight
End If
End Sub
-
Dec 6th, 2022, 04:29 AM
#5
Thread Starter
Lively Member
Re: Is there any VB6 tools or library for parsing eml files?
 Originally Posted by Arnoutdv
You mean as an email saved to disk?
Yes.
-
Dec 6th, 2022, 04:31 AM
#6
Thread Starter
Lively Member
Re: Is there any VB6 tools or library for parsing eml files?
 Originally Posted by dilettante
Example:
Code:
Option Explicit
'
'For Windows 2000 or later. Requires a reference to:
'
' Microsoft CDO For Windows Library
' Microsoft ActiveX Data Objects 2.5 Library
' tom (Text Object Model in RICHED20.dll)
'
'RichTextBox1: MultiLine = True, ScrollBars = rtfBoth
'
Private Const WM_USER As Long = &H400&
Private Const EM_GETOLEINTERFACE As Long = WM_USER + 60
Private Declare Function SendMessage Lib "user32" Alias "SendMessageW" ( _
ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Private TextDocument As tom.ITextDocument
Private Sub Dump(ByRef Name As String, ByRef Value As String)
With TextDocument.Selection
.Font.Bold = tomTrue
.Text = Name & vbNewLine
.Move tomParagraph, 1
.Font.Bold = tomFalse
.Para.SetIndents 0, 10, 10
.Text = Value & vbNewLine
.Move tomParagraph, 1
.Para.SetIndents 0, 0, 0
End With
End Sub
Private Sub Form_Load()
Dim IUnknown As stdole.IUnknown
Dim Message As CDO.Message
Dim Stream As ADODB.Stream
SendMessage RichTextBox1.hWnd, EM_GETOLEINTERFACE, 0, VarPtr(IUnknown)
Set TextDocument = IUnknown
Set Message = New CDO.Message
Set Stream = New ADODB.Stream
With Stream
.Open
.LoadFromFile "draft.eml"
.Type = adTypeText
.Charset = "us-ascii"
Message.DataSource.OpenObject Stream, "_Stream"
.Close
End With
'Clear any text present:
With TextDocument.Selection
.Expand tomStory
.Delete tomCharacter, 0
End With
With Message
Dump "From", .From
Dump "To", .To
Dump "Subject", .Subject
Dump "TextBody", .TextBody
Dump "Attachments.Count", CStr(.Attachments.Count)
End With
End Sub
Private Sub Form_Resize()
If WindowState <> vbMinimized Then
RichTextBox1.Move 0, 0, ScaleWidth, ScaleHeight
End If
End Sub
Thank you. Dilettante. I will try the code.
Basically it's just text files. I could just use regex. But I am thinking if there is something more standard to use for eml(email) files.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|