EML (Email) File Reader

Started by Deana, May 22, 2014, 10:42:39 AM

Previous topic - Next topic

Deana

EML (Email) File Reader : http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WinBatch/dotNet/Third~Party~Components/SMTPOP+Parse~EML~File.txt

Code (winbatch) Select
;***************************************************************************
;**   EML (Email) File Reader
;**
;** Purpose:  Parse Email Information from .EML Files
;** Inputs:
;** Outputs: Results in a reportview.
;** Reference:
;**          REQUIRES
;**          WinBatch 2013A or newer
;**          SMTPOP class library reads and send e-mail from WinBatch
;**             SMTPop Download: http://sourceforge.net/projects/dotnetctrlext/files/smtpop.net/SmtPop.Net%20V%200.5a/
;**             SMTPop Documentation: http://dotnetctrlext.sourceforge.net/
;**                                   http://dotnetctrlext.sourceforge.net/doc/index.html
;**
;** Developer: Deana Falk 2014.05.21
;***************************************************************************
If Version( )< '2013A'
   Pause('Notice', 'Need 2013A or Newer Version of WinBatch')
   Exit
EndIf

assemblydir = 'C:\WWW\__SCRIPT LIBRARY\DotNet\SMTPOP\smtpop_bin_0.5.1.33667'
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Load assemblies into the WinBatch process.
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If !DirExist(assemblydir)
   Pause('','')
   Exit
EndIf
ObjectClrOption('appbase',assemblydir)
ObjectClrOption ('use','smtpop, Version=0.5.1.33667, Culture=neutral, PublicKeyToken=null')

#DefineFunction udfConvertList(objectList, property)
   proplist = ''
   cnt = objectList.Count
   For x = 0 To cnt-1
      obj = objectList.Item(x)
      prop = obj.%property%()
      If prop == '' Then Continue
      If proplist == "" Then proplist = prop
      Else proplist = proplist:"|":prop
   Next
   Return proplist
#EndFunction


;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Inputs
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
eml = 'C:\TEMP\27C603F7-00000E67.eml'

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Create a class implemented by a managed assembly.
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Encoding = ObjectClrNew( 'System.Text.Encoding' )
StreamReader = ObjectClrNew("System.IO.StreamReader", eml, Encoding.ASCII)


MimeMessage = ObjectClrNew( 'SmtPop.MimeMessage')
MimeMessage.Read(StreamReader)

arrEmailData = ArrDimension(17,2)

AddressBCC = MimeMessage.AddressBCC ;The BCC: adress list
AddressBCCList = udfConvertList(AddressBCC, 'Src')
arrEmailData[0,0] = 'AddressBCC'
arrEmailData[0,1] = AddressBCCList

AddressCC = MimeMessage.AddressCC ;The CC: address list
AddressCCList = udfConvertList(AddressCC, 'Src')
arrEmailData[1,0] = 'AddressCC'
arrEmailData[1,1] =  AddressCCList

AddressFrom = MimeMessage.AddressFrom ;The From: address list
AddressFromList = udfConvertList(AddressFrom, 'Src')
arrEmailData[2,0] = 'AddressFrom'
arrEmailData[2,1] = AddressFromList

AddressSender = MimeMessage.AddressSender; The Sender: address
AddressSenderSrc = AddressSender.Src
arrEmailData[3,0] = 'AddressSender'
arrEmailData[3,1] = AddressSenderSrc

AddressTo = MimeMessage.AddressTo ;The To: address list
AddressToList = udfConvertList(AddressTo, "Src")
arrEmailData[4,0] = 'AddressTo'
arrEmailData[4,1] = AddressToList

Attachments = MimeMessage.Attachments ;Attachment list
AttachmentsList = udfConvertList(Attachments, "Filename")
arrEmailData[5,0] = 'Attachments'
arrEmailData[5,1] = AttachmentsList

Body = MimeMessage.Body ;The message body
arrEmailData[6,0] = 'Body'
arrEmailData[6,1] = Body

ContentTransferEncoding = MimeMessage.ContentTransferEncoding ;Gets or sets the "Content-Transfer-Encoding" header field
arrEmailData[7,0] = 'ContentTransferEncoding'
arrEmailData[7,1] = ContentTransferEncoding

HeaderContentType = MimeMessage.HeaderContentType ;Gets or sets the "Content-Type" header field
arrEmailData[8,0] = 'HeaderContentType'
arrEmailData[8,1] = HeaderContentType

HeaderFrom = MimeMessage.HeaderFrom ;Gets or sets the "From" header field
arrEmailData[9,0] = 'HeaderFrom'
arrEmailData[9,1] = HeaderFrom

HeaderMessageId = MimeMessage.HeaderMessageId ;Gets or sets the "Message-ID" header field
arrEmailData[10,0] = 'HeaderMessageId'
arrEmailData[10,1] = HeaderMessageId

Headers = MimeMessage.Headers ;Message header array
HeadersXMailer = Headers.Item('X-Mailer')
arrEmailData[11,0] = 'X-Mailer'
arrEmailData[11,1] = HeadersXMailer

HeaderSubject = MimeMessage.HeaderSubject ;Gets or sets the "Subject" header field
arrEmailData[12,0] = 'HeaderSubject'
arrEmailData[12,1] = HeaderSubject

HeaderTo = MimeMessage.HeaderTo ;Gets or sets the "To" header field.
arrEmailData[13,0] = 'HeaderTo'
arrEmailData[13,1] = HeaderTo

LinesTreated = MimeMessage.LinesTreated ;The number of text lines decoded to create the message
arrEmailData[14,0] = 'LinesTreated'
arrEmailData[14,1] = LinesTreated

Multipart = MimeMessage.Multipart ;Return / set the multipart flag
arrEmailData[15,0] = 'Multipart'
arrEmailData[15,1] = Multipart

Subject = MimeMessage.Subject ;The message subject
arrEmailData[16,0] = 'Subject'
arrEmailData[16,1] = Subject

; Display in WIL Dialogs Reportview Control
MyDialogFormat=`WWWDLGED,6.2`

MyDialogCaption=` EML (Email) File Reader`
MyDialogX=002
MyDialogY=059
MyDialogWidth=766
MyDialogHeight=353
MyDialogNumControls=003
MyDialogProcedure=`DEFAULT`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`231,333,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`499,333,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`001,001,758,322,REPORTVIEW,"ReportView_1",arrEmailData,DEFAULT,DEFAULT,30,2097152,DEFAULT,DEFAULT,"192|192|192"`

ButtonPushed=Dialog("MyDialog")

Exit

Deana F.
Technical Support
Wilson WindowWare Inc.

kdmoyers

The mind is everything; What you think, you become.

lionking