Jump to content

Recommended Posts

Posted (edited)

Dear All,

I need to read the body of an .eml file including its content and generate a .CSV/Excel/Word our of it.

Can any one suggest, how can we do it.

@water- I tried to explore your UDF, but got confused where to start from..

What I have : 50 .eml files.

Expected out put -   single excel/csv/word file (including the chain email)

Please help

Vipin

Edited by VipinNaudiyal
Posted

well, if you can read that, you'll see that is all clear text and what is not, is base64.
The request of "Expected out put -   single excel/csv/word" is not quite clear. Why Word, and if so, then the chain on a CSV to open in Excel ?. But you can thinker that on your own. Unless you'd like someone to give you the custom software you envision ?
I think you should use thunderbird. Give it a try. It may be all you need.

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted

@argumentum- Thanks for spending time on the forum.

Please note - My requirement is to work on any emails body content (available to me in .eml format only)  for my work that can be in csv format as well.

The important point is, it should be capturing the chain of conversation as well e.g below.

Mail 5: 13:15 PM, 22 Feb 2024

*********

------------------------------------------

Mail 4:12:27 PM, 21 Feb 2024

*********

------------------------------------------

Mail 3: 12:25 PM, 21 Feb 2024

*********

-------------------------------------------

Mail 2: 10:40 AM, 21 Feb 2024

From : vipinnaudiyal88@yahoo.co.in

To : Ramesh_@gmail.com

Hi Ramesh,

I am good, you tell, How it is going?

Regards

Vipin

-------------------------------------------------------

Mail 1: 08:30 AM, 20 Feb 2024

From : Ramesh_@gmail.com

To : vipinnaudiyal88@yahoo.co.in

Hi Vipin,

How are you, Hope you are doing Good

Regards

Ramesh

 

hope it is now clear

 

  • Moderators
Posted

Moved to the appropriate forum.

Moderation Team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted
5 hours ago, VipinNaudiyal said:

@water- I tried to explore your UDF, but got confused where to start from..

Did you try function _OLT_EML_Get that comes with the OutlookTools UDF?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

Seems the latest version of the OutlookTools UDF never made it to the forum.

Here is the function you are looking for

; #FUNCTION# ====================================================================================================================
; Name...........: _OLT_EML_Get
; Description ...: Returns the content of an EML file as a serialized stream within a single ADO Stream object.
; Syntax.........: _OLT_EML_Get($sEMLPath[, $sProperty = Default])
; Parameters ....: $sEMLPath - Path to an EML mail file e.g. "C:\Local\Test.EML"
;                  $sPropery - [optional] Property to return. See Remarks (default = keyword Default)
; Return values .: Success - Sets global variable $__g_oIMessage to the IMessage interface object and [optional] returns the specified property
;                  Failure - Returns 0 and sets @error:
;                  |1  - Could not create the IMessage object. @extended is set to the COM error code
;                  |2  - Could not create the ADO stream object. @extended is set to the COM error code
;                  |3  - Error accessing property $sProperty. Maybe the specified property does not exist?
; Author ........: maniootek, mLipok (in alph. order). See: https://www.autoitscript.com/forum/topic/207419-eml-file-with-body-base64-encoded-decoder
; Modified ......: water
; Remarks .......: The function always sets the global variable $__g_oIMessage to IMessage interface object.
;                  So you can access all properties after the function has been called.
;                  This is true even when you call the function using $sProperty to return the value of a single property.
;                  A list of available properties can be found here:
;                  iMessage: https://docs.microsoft.com/en-us/previous-versions/office/developer/exchange-server-2007/aa579703(v=exchg.80)
;+
;                  Further information:
;                  ADO: https://docs.microsoft.com/en-us/sql/ado/reference/ado-api/stream-object-ado?view=sql-server-ver15
; Related .......: _OL_ItemSaveAs
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _OLT_EML_Get($sEMLPath, $sProperty = Default)
    Local Const $sCLASSID_IMessage = "{CD000001-8B95-11D1-82DB-00C04FB1625D}" ; CLSID of the IMessage interface
    Local $oADOStream
    If Not IsDeclared("__g_oIMessage") Then
        Global Static $__g_oIMessage = ObjCreate($sCLASSID_IMessage)
        If @error Then Return SetError(1, @error, 0)
    EndIf
    $oADOStream = $__g_oIMessage.GetStream() ; Return the message in serialized (wire-transport) format in a ADO stream object
    If @error Then Return SetError(2, @error, 0)
    $oADOStream.LoadFromFile($sEMLPath)
    If @error Then Return SetError(3, @error, 0)
    $oADOStream.Flush()
    If $sProperty <> Default Then
        $sResult = Execute("$__g_oIMessage." & $sProperty)
        If @error Then Return SetError(3, @error, 0)
        Return $sResult
    EndIf
EndFunc   ;==>_OLT_EML_Get

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

Thanks @water , If I call the function like this

_OLT_EML_Get(@ScriptDir&"\2023-05-18T18_58_01Z.eml")

How will I be receiving the data.

I also heard from someone that eml data cannot be extracted directly as it has some specific format.

Can you guide what exactly i need to extract the context

Posted (edited)

In the function header you'll find the needed information :)
Use

$sTextBody = _OLT_EML_Get(@ScriptDir & "\2023-05-18T18_58_01Z.eml", "TextBody")

to get the TextBody of the EML file.

Edited by water
Removed the leading quote - was wrong

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...