• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Parsing text file

Participant ,
Mar 10, 2008 Mar 10, 2008

Copy link to clipboard

Copied

Greetings,

Could someone point me to a right direction, I am trying to grab To: email of the orignal email from Undeliverable Email text files which look like this:

Received: from scout.com by
with SMTP (Code-Crafters Ability Mail Server 2.61);
Sat, 08 Mar 2008 01:30:20 -0600
From: <admin@scout.com>
To: <admin@scout.com>
Subject: Mail System Error - Undeliverable Mail
Date: Sat, 08 Mar 2008 01:30:20 -0600
Message-ID: <5276787816.20080308013020@DOMAIN>
MIME-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

The following mail failed to be delivered...

From: admin@scout.com
Sent: Fri, 7 Mar 2008 22:30:20 -0600 CST
Subject: Search Results
To:-
Geston2@Juno.com - Rejected with: 550 Access denied...102da5f5dcf5454508c8dc=
48c8c9f861f8c9c14dd5b14c7d6d6549b16da1091c691cc51cc5a18c6c9c2525e5...

Thank you!
TOPICS
Advanced techniques

Views

280

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 11, 2008 Mar 11, 2008

Copy link to clipboard

Copied

Hi TiGGi

First read the textfile with cffile action="read"

After that, search for the Position of the "To: <" inside the String with FindNoCase. This will return the position of the first occurence of this substring.
If you're used to regular expressions, you can search for the Pattern of the "To: <admin@scout.com>" line with a regular expression. Use REFindNoCase. I think this is the better way, but more complicated.

If you have the position of the substring, you can extract the Email adress using the Mid function.

I hope this helps.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 11, 2008 Mar 11, 2008

Copy link to clipboard

Copied

thanks I will give it a try.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 13, 2008 Mar 13, 2008

Copy link to clipboard

Copied

LATEST
Use regular expressions, much faster:

<cfset match=reFindNoCase("\sto:\s+([^\s]+)\s",fileContent,1,true)>
<cfif match.pos[1]>
<cfset email=mid(fileContent,match.pos[2],match.len[2])>
</cfif>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation