• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Extract text from email
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Extract text from email


  • Subject: Extract text from email
  • From: Michael Tompsett <email@hidden>
  • Date: Mon, 13 Sep 2004 17:05:49 +0100

I need to extract a specific piece of text from the body of automated emails which we will be receiving, using Mail.

I have found a way that works but would like to know if there is a better way to go about this, one which avoids having to use textedit (or any other text editor).

Typical email body text would consist of the following:

*******************
APS-workflow
PDF onyl - APS

Date: Mon 13/ Sep / 04


Time: 15:45:15

File: CC05_14485_U1457_235.pdf
*********************

I need to get the "U1457", a unique code, out of the body of the email.
The file name is fixed length so is always characters 13-17. Below is current script.

--basic code below
--first part get the SOURCE of the email, which includes all thebody text, can't see any way to specifically get just the body text
using terms from application "Mail"
	tell application "Mail"
		set theSelectedMessages to selection
		set eachMessage to item 1 of theSelectedMessages
		set theSource to source of eachMessage
	end tell
end using terms from

--second part opens up textedit and searches for the paragraph which begins with FILE and then takes the 13-17 th character
tell application "TextEdit"
	activate
	make new document at beginning with properties {text:theSource}
	tell document 1
		set thepara to (first paragraph where it contains "File: ")
		set y to count of characters of thepara
		set u to characters 13 thru 17 of thepara as string
	end tell
end tell

many thanks

Michael
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Extract text from email
      • From: Michelle Steiner <email@hidden>
  • Prev by Date: Re: Chevrons test
  • Next by Date: Re: Address Book scripting
  • Previous by thread: Re: AppleScript Challenge
  • Next by thread: Re: Extract text from email
  • Index(es):
    • Date
    • Thread