Jump to content
Server Maintenance This Week. ×

Parsing


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

Recommended Posts

quote:

Originally posted by danjacoby:

Lots of us know how; what exactly did you have in mind?

Note the word "exactly" -- it's the key.

Two different things.

Scenerio 1. Email has a listing of 5 fields, no real separators between them. Would like to search by one of the fields, then copy the rest into their appropirate fields.

Scenerio 2. Looking at a plug-in that pulls the entire body of an e-mail into a field. I would like to pull select lines from that e-mail.

Thanks

-j

Link to comment
Share on other sites

quote:

Originally posted by nightdesigns:

Scenerio 1. Email has a listing of 5 fields, no real separators between them. Would like to search by one of the fields, then copy the rest into their appropirate fields.

Scenerio 2. Looking at a plug-in that pulls the entire body of an e-mail into a field. I would like to pull select lines from that e-mail.

Scenario 1: What do you mean by "5 fields" and "search by one of the fields"? Fields in FMP have a specific meaning which you don't appear to be using here.

Scenario 2: If you want to parse the same number of lines every time (i.e. from each e-mail), use the "Position" command and the paragraph mark for the thing whose position you're parsing. If it's a different number of lines each time, you'll probably have to parse each e-mail manually.

Link to comment
Share on other sites

I've made up a script that takes a raw email that has been copied from an email client, and parses it into the appropriate Date, To, From, Subject and Body fields, but I found that the parsing method is very specific to what email client app that I copied the email from.

You might want to search the internet to find a copy of RFC-822 "Standard for the format of ARPA internet text messages" which defines the syntax of a standard email message. That's always a good place to start.

You might also want to look into the SMTPit and POPit plug-ins that allow you to directly send and receive email from Filemaker without messing around with a separate email client app. These plug-ins have built-in functions that extract the appropriate fields painlessly.

Link to comment
Share on other sites

quote:

Originally posted by BobWeaver:

I've made up a script that takes a raw email that has been copied from an email client, and parses it into the appropriate Date, To, From, Subject and Body fields, but I found that the parsing method is very specific to what email client app that I copied the email from.


Can i see a copy of this script so that i may get an idea of what i'm doing?

Thanks

-j

Link to comment
Share on other sites

quote:

Originally posted by BobWeaver:

I wrote this script in a hurry a year ago, and didn't document it (typical of things that are for my own use). So, you can have a look at it, and if you have questions, feel free to ask.

code:


# ?Pastes and converts a raw email message from Eudora.?

Go to Layout [ EmailParse ]

New Record/Request

Paste [ RawInput ][ Select entire contents ]

Set Field [ gDelimMx, 1 ]

Set Field [ gDelim0, Position(RawInput, "Subject:", 1, 1)+8 ]

Set Field [ gDelim1, Position(RawInput, "
Link to comment
Share on other sites

All fields starting with lowercase 'g' are global fields. The gRawtext field contains the complete raw text of the email that is to be parsed. All gDelim... fields are numeric, and are used to hold the starting and ending position of a particular chunk of text.

For example, the first few lines locate the contents of the subject field by searching from the beginning of the raw message to find the position of the text "Subject:" and gDelim0 is set to the position immediately following this. Then the text is searched starting at this position to find the end of line character par.gif which indicates the end of the subject field. Then the subject field data can be extracted with the formula:

Middle(RawInput, gDelim0, gDelim1 - gDelim0)

The various other data fields are extracted in the same way. The rather messy operations on the date field are done in order to convert the date text into an actual Filemaker date field. Because of the format of the raw date text, filemaker's TextToDate function would not work reliably, so I had to create my own method.

The field gDelimMx is used to keep track of where we are as we work our way through the parsing of the message. After extracting the contents of a particular field, it is set to the position of the last text position where information was extracted. This helps avoid problems that might occur if the subject field contained text like "Re confirming our meeting Date:" which could confuse the parsing routine into thinking wrongly that the last part of this line is the start of the date field. Also, there is no keyword indicating the start of the body text. It is simply the last part of the email message after all the other fields. So, once all the other fields have been extracted, gDelimMx should contain the starting position of the body. This body text is then put in the field 'text.' The loop at the end of the script simply trims off any blank lines at the beginning of the body text.

One final note: according to RFC-822, there is no particular order to the various Date, Subject, To and From fields. Email clients normally place them in the same order for messages being sent, but received messages may be left in whatever order that the originating email client created them. I noticed that Netscape would always sort the fields of received emails, while Eudora just leaves them as is.

Hope this helps.

[ March 21, 2002, 05:47 PM: Message edited by: BobWeaver ]

Link to comment
Share on other sites

This topic is 8070 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.