Jump to content
Server Maintenance This Week. ×

Text parsing assistance needed


This topic is 3310 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I am using the MailIt plugin to pull in emails from an IMAP folder. I have the email in FM13, but I want to remove the thread (keeping only the actual response). Example:

---------

Sounds great! See you then!

 
On Apr 1, 2015, at 12:33 PM, User <[email protected]> wrote:
 
___ ITS Service Ticket 0316 ___
Can we meet at 10AM today?
---------
 
I would like everything before the "On Apr 1"....
Here is what I have now (which removes the thread but not the "On Apr 1...":
 
Left ( MailIt_Messages::Body; Position( MailIt_Messages::Body; "___"; 1; 1 ) -3 )
 
Any ideas?
 
Thank you,
 
Brian
Link to comment
Share on other sites

Let (

[

_first = Position( MailIt_Messages::Body; "___"; 1; 1 ) ;

_second = Position( MailIt_Messages::Body; "On"; 1; 1 )

];

 

 

Middle ( MailIt_Messages::Body; _first ; _second - _first )

 

)

Will return

Sounds great! See you then!

 

 

including the trailing CRLF and only works if "On" or "on" (Position() is NOT case sensitive) is never in the message body

Link to comment
Share on other sites

I would like everything before the "On Apr 1"....

 

That's a very problematic way to state your requirement, because the message itself could easily contain the string "On Apr 1". Not to mention that the actual month and day are likely to change, and counting on "On " as being the cut-off point is practically guaranteed to fail with many messages - consider for example:

Sounds great! See you on Monday! Don't forget to bring the stuff.

On May 5, 2014 ...

which would be shortened to:

Sounds great! See you 

You should look for a more reliable "marker" to signify where the message ends. We only have a single example to look at, but perhaps you could consider the first carriage return preceding the string "> wrote:¶". Assuming this string consistently appears in the line following the message (and its being unlikely to appear in the message itself), you could use:

Let ( [
mark = Position ( text ; "> wrote:¶" ; 1 ; 1 ) ;
end = Position ( text ; ¶ ; mark ; -1 )
] ;
Left ( text ; end -1 )
)
Link to comment
Share on other sites

This topic is 3310 days old. Please don't post here. Open a new topic instead.

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
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.