Title: Re: Need a script to automatically database info
You're gonna have to do <some> of the work here! ;-)

It's fairly easy. The hard part is finding the name & address line reliably. Once you have the source of the message in a variable, you can scan it line by line (which, since lines end with a Return, is the same as paragraph by paragraph). Examine each line for the thing you want; if it is found, stash it in a variable. Then, append the variables interspersed with tabs. Write the result to the file, rather than the entire source. Say you have the source in "t":

set itsLines to the paragraphs of t
set od to AppleScript's text item delimiters -- Save delimiters
set AppleScript's text item delimiters to ": " -- Or just colon, if there is no space
set grabnext to false -- Flag to grab data from next line

repeat with aLine in itsLines
    if aLine begins with "company:" then set Comp to text item 2 of aLine
    if aLine contains "It was submitted by" then set grabnext to true -- Desired data is on next line
    if grabnext then -- Get name and address
        set lparen to offset of "(" in aLine
        set rparen to offset of ")" in aLine
        set theName to text 1 thru (lparen - 1) of aLine
        set theAddr to text (lparen + 1) thru (rparen - 1) of aLine
        set grabnext to false
    end if
end repeat
set theData to theName & tab & theAddr & tab & Comp & return
-- Then write theData to the file




On or near 2/27/01 4:30 PM, Wes Plate at [EMAIL PROTECTED] observed:

> On 2/27/01 11:06 AM, "Allen Watson" wrote:
>
>> Sure. You could change this:
>
> Allen, that's great.  So much the right thing.
>
> One more question on this, and I ask because I'm not a programmer and don't
> know where to start trying to do this.
>
> The emails I get that I am processing are from a web form, and when I save
> them to the text file, they appear like this:
> ____________________________________
> <A BUNCH OF HEADER MESS>
>
> Below is the result of your feedback form.  It was submitted by:
>   NAME (EMAIL ADDRESS)
>   on Monday, February 26, 2001 at 14:30:22
> ---------------------------------------------------------------------------
>
> company: SOME COMPANY
>
> Submit: Submit
>
> ---------------------------------------------------------------------------
> ____________________________________
>
>
>
> What I'd like is that the script tosses out the header info and other
> useless text, saving it in the text file formatted as so:
>
> NAME<tab> EMAIL ADDRESS<tab> SOME COMPANY<carriage return>
>
>
> So the text file is tab delineated, with a return at the end of the line.
>
> How possible would it be to do this thing?  This would be the perfect
> end-all-be-all for me.
>
>
> Thank you.

--
Peace,
Allen Watson <[EMAIL PROTECTED]> XNS name: =Allen Watson
A Mac family since 1984 <http://home.earthlink.net/~allenwatson/>
Applescripts for Outlook Express and Entourage: <http://homepage.mac.com/allenwatson/>

Reply via email to