• 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
Re: Mail to Address Book script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mail to Address Book script


  • Subject: Re: Mail to Address Book script
  • From: "Patrick Collins" <email@hidden>
  • Date: Sat, 25 Jun 2005 08:33:38 -0700 (PDT)
  • Organization: Collinator Studios

Sorry...  I should have posted what I have so far with my last message..
    I am wondering if anyone has any suggestions on how I can improve
this..  And also I can't figure out how to get address booke to put
the_comments in the notes section of the address book...  And what if
there was a date of birth entry in the email form?  Would a separate
action need to be added to the script to "add field > Birthday" ?
Thanks so much for the help.


tell application "Mail"
    set theseMessages to selection
    set thisMessage to item 1 of theseMessages
    set myText to (content of thisMessage) as text
end tell
repeat with y in paragraphs of myText
    if y begins with "Name - " then
        set first_name to word 2 of y
        set last_name to word -1 of y
    else if y begins with "Email - " then
        set email_addr to (characters ((offset of "-" in y) + 2) thru -1) of y
as text
    else if y begins with "Email repeat - " then
        set email_addr_check to (characters ((offset of "-" in y) + 2) thru
-1) of y as text
    else if y begins with "City - " then
        set the_city to (characters ((offset of "-" in y) + 2) thru -1) of y
as text
    else if y begins with "State - " then
        set the_state to (characters ((offset of "-" in y) + 2) thru -1) of y
as text
    end if
end repeat
set the_comments to (characters ((offset of "comments" in myText) + 9)
thru -1) of myText as text
tell application "Address Book"
    set myCard to make new person with properties {first name:first_name,
last name:last_name}
    tell myCard
        make new address at end of addresses with properties {city:the_city,
state:the_state, label:"Home"}
    end tell
    save addressbook
end tell
tell application "Address Book"
    set myID to id of myCard
end tell
open location "addressbook://" & myID

--------------------------------------------------------------------------

Ok...  Say I have an email that says in the body:


      Name - Patrick Shmatrick

      Email - email@hidden

      Email repeat - email@hidden

      City - New Kensington

      State - pa

      Comments
      I love your company.. can I work there some day?  This is a fake
comment.


What is the best approach to capture first & last name, email, city,
state, comments into variables that can then be pasted into a new card
in address book?  I already have a script working to create a card in
address book, however, I am just not sure how to proceed to get all of
the information off of a current email being viewed...

notice that there is a dash after each catagory except Comments---  (I
am basing this off of a web generated email that is sent when someone
orders a product, so I don't think I have much control on making the
Comments catagory's appearance uniform with the others..)

thanks.
-patrick

Michelle Steiner wrote on 6/25/05, 1:09 AM:

 >
 > On Jun 24, 2005, at 9:12 PM, Patrick Collins wrote:
 >
 > > I am trying to create a script that will effectively take an email
 > > from
 > > Paypal (in os x mail.app), and extract the purchaser's name, address,
 > > and other information and create a contact in addressbook and add
 > > it to
 > > a group (titled paypal).  I just wondered if anyone out there has done
 > > anything similar and might be willing to share their code to help
 > > get me
 > > in the right direction.
 >
 > If you provide us with the format that the information comes in in
 > mail, we might be able to figure something out for you.
 >
 > --
 > You can not change the world without perforce changing yourself.
 >



 _______________________________________________
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

  • Prev by Date: Re: Mail to Address Book script
  • Next by Date: Re: Mail to Address Book script
  • Previous by thread: Re: Mail to Address Book script
  • Next by thread: Set Focused of Static Text
  • Index(es):
    • Date
    • Thread