How to parse a email and reply to the parsed email

How to parse a email and reply to the parsed email

Post by karenmiddl » Sun, 24 Oct 2004 07:08:20


have a requirement to write a email handler that can receive a
incoming email and do parsing and based on some of the keywords to
perform a appropriate task handler and reply to the email or action
the email.

Can somebody please share the code and how to implement a process by
which a DTS ActiveX VB Script or T-SQL code can act as a email handler
and how can we have this code to automatically handle on a incoming
email.

Thanks
Karen
 
 
 

How to parse a email and reply to the parsed email

Post by Joe Fawcet » Sun, 24 Oct 2004 18:46:14


What email system are you running?

--

Joe (MVP)

 
 
 

How to parse a email and reply to the parsed email

Post by karenmiddl » Mon, 25 Oct 2004 10:56:12


Unfortunately we are running Lotus Notes I know it is not the best
system to use but we are struck with it.

Thanks
Karen
 
 
 

How to parse a email and reply to the parsed email

Post by Miyah » Mon, 25 Oct 2004 13:19:11


I can't understand your hope completely, because of my poor English ability.
So, the following script may not be helpful.
I use this script to check new Notes mails in plain text.
(Of course, in the Notes of Japanese edition.)
Pay attention to the comment lines before you try it.

Dim FS, WS ,aFile, nSs, nDb, nVw, nDoc
Dim MailServer ,MailFile, From, dDate, Title, Body, Buf
Dim oFile, tFile, LastTime
oFile = "NewMail.txt": tFile = "LastTime.txt"
Set WS = CreateObject("WScript.Shell")
If Not WS.AppActivate("Lotus Notes Desktop") Then
' ^^ This line should be modified by the 'Notes' version
MsgBox "The 'Notes' isn't running"
Set WS = Nothing: WScript.Quit
End If
LastTime = "2004/10/24"
' ^^ This line should be modified by DateTimeFormat of the system
Set FS = CreateObject("Scripting.FileSystemObject")
If FS.FileExists(tFile) Then
Set aFile = FS.OpenTextFile(tFile, 1)
LastTime = aFile.ReadLine
aFile.Close
End if
Set aFile = FS.CreateTextFile(tFile)
aFile.Write Now & vbCrLf
aFile.Close
Set nSs = CreateObject("Notes.NotesSession")
MailServer = nSs.GetEnvironmentString("MailServer", True)
MailFile = nSs.GetEnvironmentString("MailFile", True)
Set nDb = nSs.GetDataBase(MailServer, MailFile)
Set nVw = nDb.GetView("($Inbox)")
Set nDoc = nVw.GetFirstDocument
On Error Resume Next
Do Until nDoc Is Nothing
dDate = nDoc.GetFirstItem("DeliveredDate").Text
If CDate(dDate) > CDate(LastTime) Then
From = nDoc.GetFirstItem("PName").Text
' ^^ This line may be modified by mail database template.
Title = nDoc.GetFirstItem("Subject").Text
Body = nDoc.GetFirstItem("Body").Text
Buf = Buf & "Sender : " & From & vbCrLf
Buf = Buf & "Subject : " & Title & vbCrLf
Buf = Buf & "Date : " & dDate & vbCrLf
Buf = Buf & "Body : " & vbCrLf & Replace(Body, vbLf, vbCrLf) & vbCrLf
Buf = Buf & String(65, "=") & vbCrLf
End If
Set nDoc = nVw.GetNextDocument(nDoc)
Loop
Set nDoc = Nothing : Set nVw = Nothing : Set nDb = Nothing
Set nSs = Nothing
If Buf = "" Then
MsgBox "No new mail"
Else
Set aFile = FS.CreateTextFile(oFile)
aFile.Write Buf
aFile.Close
WS.Run oFile
End If
WScript.Quit

--
Miyahn (Masataka Miyashita) JPN
Microsoft MVP (Office Systems - Excel)
XXXX@XXXXX.COM