Here's the VB code I use to take the message, parse it, and put it in
the database. It calls some library functions of mine, but should be
pretty straightforward to figure out what its doing. Nothing special,
its pretty hacked together, but it works. Please don't make fun of me
for my ugly code. :)
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Brian
> Sent: Saturday, February 22, 2003 9:31 AM
> To: [EMAIL PROTECTED]
> Subject: RE: [IMail Forum] Mailing List on the Web
>
>
> I wouldn't mind trying the same thing.
>
> But I'm at a loss to finding any syntax guides for parsing
> through an email message.
>
> You couldn't point me to any resources or share a snippet of code?
>
> Thanks.
>
> b
>
> ---------- Original Message ----------------------------------
> From: "Greg Deputy" <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> Date: Sat, 22 Feb 2003 08:57:07 -0800
>
> >Its not tough to do if you can write a few lines of code. I
> set up an
> >alias on a mail server that dumps the message to a small application
> >that writes the email to a database, then a pretty
> straightforward web
> >page to display the archives from the database. I also added a full
> >text search using SQL's full text indexing.
> >
> >> -----Original Message-----
> >> From: [EMAIL PROTECTED]
> >> [mailto:[EMAIL PROTECTED] On Behalf Of
> A. Clausen
> >> Sent: Friday, February 21, 2003 1:04 PM
> >> To: IMail Mailing List
> >> Subject: [IMail Forum] Mailing List on the Web
> >>
> >>
> >> I asked this question a month or two ago, but lost the
> >> message of the person who responded. What I need is software
> >> to take an IMail mailing list and put an archive of it on the web.
> >>
> >> --
> >> A. Clausen
> >>
> >>
> >> To Unsubscribe: http://www.ipswitch.com/support/mailing-lists.html
> >> List Archive:
> >> http://www.mail-archive.com/imail_forum%> 40list.ipswitch.com/
> >>
> >> Knowledge Base/FAQ:
> >> http://www.ipswitch.com/support/IMail/
> >>
> >
> >
> >To Unsubscribe: http://www.ipswitch.com/support/mailing-lists.html
> >List Archive:
> >http://www.mail-archive.com/imail_forum%40list.ipswitch.com/
> >Knowledge Base/FAQ: http://www.ipswitch.com/support/IMail/
> >---
> >[This E-mail was scanned for Viruses and Spam by Richmond.com]
> >
> >
>
> To Unsubscribe: http://www.ipswitch.com/support/mailing-lists.html
> List Archive:
> http://www.mail-archive.com/imail_forum%> 40list.ipswitch.com/
>
> Knowledge Base/FAQ:
> http://www.ipswitch.com/support/IMail/
>
Sub Main()
On Error GoTo Oops
Dim sCommand As String
Dim sMessage As String
Dim iFile As Integer
Dim sLine As String
Dim sSQL As String
Dim sMessageId As String
Dim sMessageDate As String
Dim sMessageFrom As String
Dim sMessageTo As String
Dim sSubject As String
Dim sBody As String
Dim iLoc As Long
Dim oConn As New ADODB.Connection
Dim sList As String
sCommand = Command
WriteToLog "Command=" & sCommand
iFile = FreeFile
'open file
WriteToLog "opening file"
Open sCommand For Input As #iFile
WriteToLog "reading file"
Do Until EOF(iFile)
Line Input #1, sLine
sMessage = sMessage & sLine & vbCrLf
Loop
WriteToLog "Message at " & Now
'parse message
sMessage = Replace(sMessage, "'", "`")
sMessageId = GetUniqueString()
sMessageDate = Mid(sMessage, InStr(1, sMessage, "Date", vbTextCompare))
sMessageDate = Trim(Mid(sMessageDate, 6))
sMessageDate = Left(sMessageDate, InStr(sMessageDate, vbCrLf) - 1)
sMessageFrom = Mid(sMessage, InStr(1, sMessage, vbCrLf & "From", vbTextCompare))
sMessageFrom = Trim(Mid(sMessageFrom, 9))
sMessageFrom = Left(sMessageFrom, InStr(sMessageFrom, vbCrLf) - 1)
sMessageFrom = Replace(sMessageFrom, ">", "")
sMessageFrom = Replace(sMessageFrom, "<", "")
sMessageTo = Mid(sMessage, InStr(1, sMessage, vbCrLf & "To", vbTextCompare))
sMessageTo = Trim(Mid(sMessageTo, 7))
sMessageTo = Left(sMessageTo, InStr(sMessageTo, vbCrLf) - 1)
sMessageTo = Replace(sMessageTo, ">", "")
sMessageTo = Replace(sMessageTo, "<", "")
sSubject = Mid(sMessage, InStr(1, sMessage, vbCrLf & "Subject", vbTextCompare))
sSubject = Trim(Mid(sSubject, 12))
sSubject = Left(sSubject, InStr(sSubject, vbCrLf) - 1)
sList = sSubject
If InStr(sList, "[") > 0 Then
sList = GetWord(sList, "[", 2)
sList = GetWord(sList, "]")
Else
sList = "Unknown"
End If
sBody = Trim(Mid(sMessage, InStr(1, sMessage, vbCrLf & vbCrLf) + 4))
'write to DB
sSQL = "Insert into messages(messagedate,archivedate,messagefrom,messageto,subject" & _
",messageraw,body,list) values('" & sMessageDate & "',getdate(),'" & sMessageFrom & _
"','" & sMessageTo & "','" & sSubject & "','" & sMessage & "','" & sBody & "','" &
sList & "')"
WriteToLog "Inserting Into DB on paweb1" 'sSQL
oConn.Open gsConnectionString
oConn.Execute sSQL
oConn.Close
Cleanup:
On Error Resume Next
Set oConn = Nothing
Close iFile
Kill sCommand
Exit Sub
Oops:
WriteToLog Err.Description
WriteToLog sSQL
Resume Cleanup
End Sub