Parker Software Ltd Homepage
Forum Home Forum Home > Email2DB Email Parser > Scripting > Scripting Samples
  New Posts New Posts RSS Feed: Saving incoming emails as text files.
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Saving incoming emails as text files. - Event Date: 02 Feb 2006 - 02 Feb 2006

 Post Reply Post Reply
Author
Message
Stephen View Drop Down
Admin Group
Admin Group
Avatar

Joined: 21 Oct 2005
Location: Stoke on Trent
Posts: 1389
Post Options Post Options   Quote Stephen Quote  Post ReplyReply Direct Link To This Post Calendar Event: Saving incoming emails as text files.
    Posted: 02 Feb 2006 at 6:05pm
This sample Action Script shows how to save incoming emails as text files into a folder on your PC.

The sample saves emails to a folder called C:\Mail\

You could easily tweak the sample to change the location and naming.

The text files will be RFC2822 format with the headers first followed by a blank line and the MIME text.

Replace MSG_MimeText with MSG_Body if you just want to save the email text and not all attachments also (you can still use the Attachments save action to save attachments separately).

Sample here:
http://www.email-2-db.com/images/script-saveemailtext.gif


Edited by Daniel - 22 Aug 2008 at 1:01pm
Stephen Parker
Back to Top
James Horton View Drop Down
Admin Group
Admin Group
Avatar
Technical Support

Joined: 01 Jun 2009
Location: Stoke-on-Trent
Posts: 275
Post Options Post Options   Quote James Horton Quote  Post ReplyReply Direct Link To This Post Posted: 05 Apr 2011 at 4:32pm
Here is a written version of the code.

' Action Script
' This script will fire when the Trigger fires. Use it to perform custom actions.
Sub Main()
Dim H As Integer
Dim FN As Integer
Dim FName As String
' saving an email as an RFC .eml file
On Error GoTo mnErr
FN=FreeFile
FName="C:\Mail\" & MSG_UID & Format(Date,"yyyymmdd") & Format(Time,"hhmmss") & ".eml"
Open FName For Output As FN
'write headers
For H=1 To MSG_HeaderCount
Print #FN,MSG_Header(H) & ": " & MSG_HeaderValue(H)
Next H
Print #FN,""
'write fulltext
Print #FN,MSG_MimeText
Close FN
Call AddToLog("Email saved to" & FName)
Exit Sub
mnErr:
Call AddToLog("Script errr: " & Err.Description)
End Sub


Edited by James Horton - 05 Apr 2011 at 4:40pm
Best Regards,

James Horton
Technical Analyst
Parker Software
Back to Top
StuartBrook View Drop Down
New User
New User


Joined: 20 May 2011
Location: London, UK
Posts: 1
Post Options Post Options   Quote StuartBrook Quote  Post ReplyReply Direct Link To This Post Posted: 20 May 2011 at 9:23am
Hi,
How can i save a copy of the message body as a file without the message header appearing in the file?  I can save the message as a TXT, but the first few lines are the original email header, and i don't require that detail, just the message body.
Thank you.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down



This page was generated in 0.063 seconds.
These are the forums for Parker Software, developers of Live Chat Software: WhosOn and Email Automation Software: Email2DB.