Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Enthusiast Zone > Classic Macs and Mac OS > Slightly OT, but I need help with Apple Script.

Slightly OT, but I need help with Apple Script.
Thread Tools
Fresh-Faced Recruit
Join Date: Jul 2001
Location: Tennessee
Status: Offline
Reply With Quote
Jan 9, 2002, 01:50 PM
 
Sorry for the long post....but I didn't know any other way to do this...How do I add a closing tag to the following script? I want to close the contact window after it is added to my address book. I have about 5000 addresses to add, so I can't have outlook open all 5000 windows.


global dontDialogMeMan
set dontDialogMeMan to false

tell application "Script Editor"
activate
-- figure out what messages to process
set theMessages to «class CMgs»
repeat with theMsg in theMessages
my ProcessMsg(theMsg)
end repeat
end tell

-- process the messages
on ProcessMsg(theMsg)
tell application "Script Editor"
--check the to field (in case this is a mailing list)
--get the recipient info
set recipientAddress to the «class addr» of «class rcpt» 1 of theMsg
set recipientdisplayName to the «class dspn» of recipientAddress
set recipientEmailAddress to the «class addr» of recipientAddress

my updateContact(recipientdisplayName, recipientEmailAddress, true)

--get the sender info
set SenderdisplayName to the «class dspn» of the «class sndr» of theMsg
set SenderEmailAddress to the «class addr» of the «class sndr» of theMsg

my updateContact(SenderdisplayName, SenderEmailAddress, true)

end tell
end ProcessMsg

on updateContact(thedisplayName, theEmailAddress, useDialog)
global dontDialogMeMan
tell application "Script Editor"
if thedisplayName is "" then --no display name
set matchedContacts to {}
try
set matchedContacts to every «class cAbE» whose contents of «class cEmA» 1 is theEmailAddress --just check email address 1
end try
if number of items in matchedContacts is 0 then
open (make new «class cAbE» with properties {«class addr»:theEmailAddress})
set dontDialogMeMan to true
else
if useDialog and not dontDialogMeMan then
set theResponse to display dialog "The address " & (theEmailAddress as string) & ¬
" is already in the address book: Do you want to edit this contact?" buttons {"Yes", "No"} default button 2 with icon 2 giving up after 20
if ((gave up of theResponse) or (button returned of theResponse is "No")) then
-- do nothing
else
repeat with x in matchedContacts
open x
end repeat
end if
end if
end if
else
if «class cAbE» thedisplayName exists then
set theContact to «class cAbE» thedisplayName
if class of theContact is list then
set theContact to item 1 of theContact
end if
-- see if email address already exists anywhere in this contact
set emailAddress to every «class cEmA» of theContact whose contents is (contents of theEmailAddress)
if number of items of emailAddress is 0 then
-- add email address
make new «class cEmA» at theContact with properties {contents:theEmailAddress}
open theContact
end if
if useDialog and not dontDialogMeMan then
set theResponse to display dialog "Contact: " & thedisplayName & " with email address: " & contents of theEmailAddress & ¬
" already exists. Do you want to edit it?" buttons {"Yes", "No"} default button 2 with icon 2 giving up after 20
if ((gave up of theResponse) or (button returned of theResponse is "No")) then
--do nothing
else
open theContact
end if
end if
else
open (make new «class cAbE» with properties {«class dspn»:thedisplayName, «class addr»:theEmailAddress})
end if
end if
end tell
end updateContact
     
Moderator Emeritus
Join Date: Aug 2000
Location: New York City
Status: Offline
Reply With Quote
Jan 9, 2002, 09:37 PM
 
Transferring into the Mac OS forum. Find thread there.


MP 2 x 2.8 and etc.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -4. The time now is 07:10 AM.
All contents of these forums © 1995-2015 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2015, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2