How to parse a email with attachment- Miyahn please help



Hi Miyahn

The code here works fine to extract the email but my problem is I want
to extract a text file attachment that comes with the email.

I would greatly appreciate if you could share the code that enables to
download the attachment which is a text file to a folder than just
parse the email.

Thanks
Karen


Subject: Re: How to parse a email and reply to the parsed email
View: Complete Thread (4 articles)
Original Format
Newsgroups: microsoft.public.scripting.vbscript
Date: 2004-10-23 21:21:24 PST


"Karen Middleton" wrote in message news:a5fd468a.0410231756.4f62dcb9@xxxxxxxxxxxxxxxxxx
> > What email system are you running?
>
> Unfortunately we are running Lotus Notes I know it is not the best
> system to use but we are struck with it.

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)
HQF03250@xxxxxxxxxxx
.