Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
10.1
10.2
10.3
10.4
10.5
11.0
11.1
11.2
11.3
11.4
Statistic
FMM
Blog
Parses an email.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
EmailParser | 5.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example | Flags |
---|---|---|---|
EmailSource | The source code of an email as text. e.g. as downloaded via IMAP/POP3 functions in CURL. |
$EmailContent | |
Encoding | The text encoding for text parameter. Default is native. Possible encoding names: ANSI, ISO-8859-1, Latin1, Mac, Native, UTF-8, DOS, Hex, Base64 or Windows. More listed in the FAQ. |
UTF8 | Optional |
Returns Reference number or error.
Parse an email and copy data into records:
Set Variable [$email; Value:MBS("EmailParser.Parse"; Email Parser::Input)]
If [MBS("IsError") = 1]
Show Custom Dialog ["Failed to parse email."; Middle($email; 7; Length($email))]
Exit Script []
End If
#Show text:
Set Field [Email Parser::Subject; MBS("EmailParser.Subject"; $email)]
Set Field [Email Parser::PlainText; MBS("EmailParser.PlainText"; $email)]
Set Field [Email Parser::HTMLText; MBS("EmailParser.HTMLText"; $email)]
#find all addresses
Set Variable [$EmailRecordID; Value:Get(RecordID)]
Set Variable [$i; Value:0]
Set Variable [$c; Value:MBS("EmailParser.AddressCount"; $email)]
If [$c > 0]
Go to Related Record [Show only related records; From table: “Address”; Using layout: “Address” (Address)]
Go to Layout [“Address” (Address)]
Delete All Records [No dialog]
Loop
Set Variable [$Name; Value:MBS("EmailParser.Address"; $email; $i; "name")]
Set Variable [$emailAddress; Value:MBS("EmailParser.Address"; $email; $i; "email")]
Set Variable [$type; Value:MBS("EmailParser.Address"; $email; $i; "type")]
New Record/Request
Set Field [Address::Type; $type]
Set Field [Address::Email; $emailAddress]
Set Field [Address::Name; $name]
Set Field [Address::EmailID; $EmailRecordID]
Commit Records/Requests [Skip data entry validation; No dialog]
#next
Set Variable [$i; Value:$i + 1]
Exit Loop If [$i = $c]
End Loop
End If
#find all attachments
Set Variable [$i; Value:0]
Set Variable [$c; Value:MBS("EmailParser.AttachmentCount"; $email)]
If [$c > 0]
Go to Related Record [Show only related records; From table: “Attachment”; Using layout: “Attachment” (Attachment)]
Go to Layout [“Attachment” (Attachment)]
Delete All Records [No dialog]
Loop
Set Variable [$Name; Value:MBS("EmailParser.Attachment"; $email; $i; "filename")]
Set Variable [$content; Value:MBS("EmailParser.Attachment"; $email; $i; "container")]
New Record/Request
Set Field [Attachment::Content; $content]
Set Field [Attachment::FileName; $name]
Set Field [Attachment::EmailID; $EmailRecordID]
Commit Records/Requests [Skip data entry validation; No dialog]
#next
Set Variable [$i; Value:$i + 1]
Exit Loop If [$i = $c]
End Loop
End If
#find all inline graphics
Set Variable [$i; Value:0]
Set Variable [$c; Value:MBS("EmailParser.InlineCount"; $email)]
If [$c > 0]
Go to Related Record [Show only related records; From table: “InlineGraphics”; Using layout: “InlineGraphics” (InlineGraphics)]
Go to Layout [“InlineGraphics” (InlineGraphics)]
Delete All Records [No dialog]
Loop
Set Variable [$Name; Value:MBS("EmailParser.Inline"; $email; $i; "filename")]
Set Variable [$content; Value:MBS("EmailParser.Inline"; $email; $i; "container")]
New Record/Request
Set Field [InlineGraphics::Content; $content]
Set Field [InlineGraphics::FileName; $name]
Set Field [InlineGraphics::EmailID; $EmailRecordID]
Commit Records/Requests [Skip data entry validation; No dialog]
#next
Set Variable [$i; Value:$i + 1]
Exit Loop If [$i = $c]
End Loop
End If
Go to Layout [original layout]
#find a header
Set Variable [$i; Value:0]
Set Variable [$c; Value:MBS("EmailParser.HeaderCount"; $email)]
If [$c > 0]
Loop
Set Variable [$HeaderName; Value:MBS("EmailParser.Header"; $email; $i; "name")]
If [$HeaderName = "X-Mailer"]
Set Variable [$HeaderValue; Value:MBS("EmailParser.Header"; $email; $i; "value")]
Set Field [Email Parser::Mailer; $HeaderValue]
End If
#next
Set Variable [$i; Value:$i + 1]
Exit Loop If [$i = $c]
End Loop
End If
#cleanup
Set Variable [$r; Value:MBS("EmailParser.Free"; $email)]
Extract email text:
Set Variable [$EmailID; Value:MBS( "EmailParser.Parse"; email::raw)]
Set Field [email::raw_plainText; MBS( "EmailParser.PlainText"; $EmailID )]
Set Field [email::raw_htmltext; MBS( "EmailParser.HTMLText"; $EmailID )]
Set Variable [$r; Value:MBS( "EmailParser.Free"; $EmailID)]
Read emlx file:
# emlx test in file Contacts
Set Variable [ $path ; Value: "/Users/cs/Desktop/28213.emlx" ]
Set Variable [ $emailSourceText ; Value: MBS( "Text.ReadEMLXFile"; $path; "UTF-8") ]
If [ MBS("IsError") = 0 ]
Set Variable [ $email ; Value: MBS( "EmailParser.Parse"; $EmailSourceText; "UTF8") ]
If [ MBS("IsError") = 0 ]
Show Custom Dialog [ "Email subject" ; MBS( "EmailParser.Subject"; $email ) ]
Set Variable [ $r ; Value: MBS( "EmailParser.Free"; $email ) ]
End If
End If
Created 24th September 2015, last changed 20th September 2020
EmailParser.MessageID - EmailParser.ParseContainer
Feedback: Report problem or ask question.