Adding a country to an address in Addressbook with AppleScript

Hi,
I'm stuck on a simple script to add a certain country to every contact that hasn't one in my Address Book.
This is the code at the core:
repeat with thisPerson in every person
repeat with thisAddress in every address of thisPerson
if (country of thisAddress) is "" then
set (country of thisAddress) to "My Country"
end if
end repeat
end repeat
The log however shows a 'missing value' every time I want to get the country of an address. How can I fix this?
(And how can I format code in this forum?)
Thank you for any input,
christian

The log however shows a 'missing value' every time I want to get the country of an address. How can I fix this?
That's correct - there is a difference between 'missing value' (no value recorded) and "" (an empty string).
The solution is simple - check for 'missing value' - rather obscurely, 'missing value' is an AppleScript keyword used just for that purpose:
  if (country of thisAddress) is missing value then
    set country of thisAddress to "My Country"
  end if

Similar Messages

  • How do I delete a custom date (in addressbook) with applescript

    I can't figure out how to delete a custom date for a contact.  I've worked with addresses and emails, phone numbers, but this one eludes me.
    I want the script to go through all my contacts and delete every custom date whose label is "Mail Received"
    I've searched and found a few people who had problems deleting custom dates, but I can't find an answer...
    Thanks,

    Hi,
    Delete a custom date  doesn't work,  it's a bug.
    Setting the value of the custom date to "missing value" works here (Mac OS X 10.5.8), but this generates an error (error : AppleEvent handler failed), I use a try block
    Try this script
    tell application "Address Book"
         repeat with theseDates in (get custom dates of people whose its label = "Mail Received")
              repeat with thisDate in theseDates
                   try
                        set value of thisDate to missing value
                   end try
              end repeat
         end repeat
         save
    end tell

  • Old operating systems allowed you to click on recipients when sending emails without adding a comma after each address. Now with the new and improved system, I have to stop and add a comma after each name. How can I avoid this?

    With the new OSX system, whenever I send an email with multiple recipients, I need to physically add a comma after each address. I never needed to do that with all the other older systems, it was done automatically. How can I fix this frustrating glitch?

    option discovered in preferences. Really this and any feature that moves deletes or edits a users data should as far as possible be OFF BY DEFAULT. It shouldn't by default and without the users specific say do this dangerous and unnecessary thing without even letting the user know what it's doing!!! And then cause me a few hours (as i'm new to mac) searching for the option so as to switch it off. If i hadn't noticed the status cage declaring that it was copying files then i might never have twigged that this insane thing was occurring. And if i hadn't of noticed i would have been left maintaining the contents of the folder i copied the files to, the folder which as far as i was informed and so believed was also the location of the music files i was playing. How does Apple justify this 'genius' piece of software non-design? Surely it will hurt no one if this was off by default for new users - overall at least i dare say it would cause a lot less distress in the future for the unsuspecting public at large. Thanks for the support.

  • Adding folder alias to finder Sidebar in Lion with AppleScript

    I am creating 2 AppleScripts to automate mounting Windows shared drives on Lion Macbook Airs.  The first creates an alias on the user's desktop to the user's shared drive.  This is functional and doing what I want it to do.
    The 2nd script attempts to create a favorite to the alias in Finder's sidebar.  Unfortunately, I can't seem to get this script to work.
    I am attempting to create an alias on a user's desktop to a folder in a Windows network share.  Here is my applescript:
    set user_name to (short user name of (system info))
    tell application "Finder"
      activate
              set myFolder to ((home as text) & "Desktop:" & user_name)
      select myFolder
              tell application "System Events"
      keystroke "t" using command down
              end tell
    end tell
    The script runs, Finder opens to the user's folder, but nothing is added to the side.
    Any help would be very much appreciated!

    Nevermind... figured it out.  I needed to open the folder for the command to work, so I added:
    open myFolder after the select line.

  • "Message Sending Failed" after adding the country code number?

    I changed a contact's number (in this case I simply added a country code to it) and now the messages aren't sending to the number I changed it to. How can I get the SMS library to redirect itself to the new number? When I delete the contact, the SMS library shows that it is still sending to the old number.
    The only solution I've found on the internet so far is delete the SMS library. I have tested it with other numbers in which I added a country code to as well and it works. But the text messages for this particular contact are very important and I need to keep them. Is there ANY way I can redirect an old SMS library to a new number?

    Hi, Thilina66.  You say you have entered the country code but still cannot make international calls.  I suppose you are adding the international access code before the country code.  This internaltional access code (011 in the US, 00 in Europe, etc.) can be substituted by adding a + sign before the country code.
    For example, to call a number in the UK from the US you have to dial:
    011 44 7540 267898
    or
    +44 7540 267898
    To call a number in the US from the UK you have to dial:
    00 1 212 456 1470
    or
    +1 212 456 1470
    Please check that the contact number in your address book is correctly written if you are dialing directly from the address book or that you enter the correct numbers in the keyboard if you are dialing from the keyboard.

  • Even after adding the country code i can't seem to make any international calls.im not sure if this is relevant but apparently, the option dial assist is not to be found on my setting.pls direct me...thank you.and my phone moddle is 5s(A1457)gold

    even after adding the country code i can't seem to make any international calls.im not sure if this is relevant but apparently, the option dial assist is not to be found on my setting.pls direct me...thank you.and my phone moddle is 5s(A1457)gold  eddition.

    Hi, Thilina66.  You say you have entered the country code but still cannot make international calls.  I suppose you are adding the international access code before the country code.  This internaltional access code (011 in the US, 00 in Europe, etc.) can be substituted by adding a + sign before the country code.
    For example, to call a number in the UK from the US you have to dial:
    011 44 7540 267898
    or
    +44 7540 267898
    To call a number in the US from the UK you have to dial:
    00 1 212 456 1470
    or
    +1 212 456 1470
    Please check that the contact number in your address book is correctly written if you are dialing directly from the address book or that you enter the correct numbers in the keyboard if you are dialing from the keyboard.

  • Adding multiple e-mail alias addresses to an account

    Can someone please tell me how to add another e-mail address to my Mail account. I have tried using info from the Mail Help file, both "adding another account" and "adding multiple e-mail alias addresses to an account". Each time when I try to send a test message to or from the added e-mail address, I get the same message: "Cannot send message using the server mail.bellsouth.net. Use the Pop-up menu below to try a different outgoing mail server". The only pop-up is smtp .Mac.
    I have tried both methods shown in the HELP file and get the same message. I would really appreciate your help.

    Are you trying to add a second email account to Mail, or just add a second "(apparently) from" address to an existing account?
    If the former, we need to know some more detail, like:
    (1) who is the existing account, .mac or bellsouth?
    (2) Which are you trying to add, .mac or bellsouth?
    (3) I assume your ISP is Bell South?
    (4) What are the names of the smtp servers and what are their respective smtp server port numbers?
    (5) Are either of them using SSL on the smtp server?
    (6) I don't remember whether Tiger Mail has it or not, but in Leopard Mail, on the menu bar under "Window" there is a selection "Connection Doctor." If applicable to Tiger Mail, what does it say about your connections?
    (7) Which account can you send mail through and which one can't you send mail through?
    (8) Are your receiving mail okay through either or both accounts? Which one(s)?
    Now if you are trying to add a second "(apparently) from" address to an existing account, in Mail Prefs > Accounts > mail account > Email Address, just add a second email address separated by a comma like so:
       [email protected], [email protected] 
    You could have an issue with bellsouth or .mac requiring the domain name in the apparently from email address to match the domain name of the smtp mail server.

  • Today I deleted a gmail account using my computer.  I also added a new work gmail  address.  Now I want to sync my phone and tablet with the new email address.  I've looked all over and can't find  out how to do it.

    Today I deleted a gmail account using my computer.  I also added a new work gmail  address.  Now I want to sync my phone and tablet with the new email address.  I've looked all over and can't find  out how to do it.
    Peg

        Hi there T&P63385!
    Look no further! I have the answer for you! You can add a new email account to your android device by following these steps: http://support.verizonwireless.com/clc/devices/knowledge_base.html?id=31401
    Now I do want to let you know that your phone has a "main" gmail account. If this "main" gmail account was the one you deleted it may be best that you reset your phone and activate it to your new gmail address.
    The reason I recommend doing this is all of your purchased application information is also tied to your gmail.
    Ensure your personal information is backed up (contacts, pictures, etc) and follow these steps to Hard Reset your phone:http://support.verizonwireless.com/clc/devices/knowledge_base.html?id=31308
    Let me know if you have any other questions!
    Thanks,
    MelissaM_VZW
    Follow us on Twitter @vzwsupport

  • Every single website, or link within a website page is being added to my location bar/address bar drop down menu. How can I stop this? This just started happening.

    Every single website url address, or url address within a website page is being added to my location bar/address bar drop down menu.
    I don't want everything added or saved in the location bar. Only urls that I used a lot used to be saved there but now every single url (and url within a url)I visit is being added to it.
    How can I stop this? This just started happening.
    I'm sure it's a simple browser setting but I've checked and nothing gives an option to control this.
    Firefox 3.0.17
    Windows XP
    == User Agent ==
    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.17) Gecko/2009122116 Firefox/3.0.17

    A possibility is to open the links via the right-click context menu or a middle-click in a new tab to make sure that Firefox sees them as regular links.

  • HT201318 I registered my apple ID and Icloud with a US address, and live in Switzerland. I do not own a US credit card. Now that I need to buy more storage with my swiss credit card, I can't change the country's billing address from the US to my swiss one

    I registered my apple ID and Icloud with a US address, and live in Switzerland. I do not own a US credit card. Now that I need to buy more storage with my swiss credit card, I can't change the country's billing address from the US to my swiss one. HELP PLS?

    Did you actually watch the movie? You get 30 days in which to view it and if you didn't watch it, that could be why you are getting that message. If you have watched the movie and you're sure that is has expired by now, contact iTunes Store Support and seek their help.
    Change the country in the upper left. - and click on Purchases, billing and redemption to proceed.
    https://getsupport.apple.com/Issues.action

  • How to display the field "Country" in the Address Book UI ?

    How to display the field "Country" in the Address Book UI ?

    Using an add-on, MoreFunctionsForAddressBook gives you that opportunity.

  • I have just added one of my email addresses to my newer desktop on MAC mail, how do I download my full email history?

    I have just added one of my email addresses to my newer desktop on MAC mail, how do I download my full email history? At the moment it is only downloading emails from September 2014 - present.
    I have a MAC OS X version 10.8.5.
    Any help would be appreciated.
    Thank you.

    Good luck with this!!!
    EVEN USING what WAS my Username, this is the exact problem I am having having entered my correct ID and Password.
    Rgds
    Rod

  • I cannot order photo prints from iphoto. Error says that the delivery address is in an unsupported country. The address and my account are in the UK. Does anyone have any ideas?

    I cannot order photo prints from iphoto. Error says that the delivery address is in an unsupported country. The address and my account are in the UK. Does anyone have any ideas?

    I cannot order photo prints from iphoto.
    Are you trying to print from iPhoto on your Mac or iPad/iPhone? If you are trying to print form yor Mac, check, if the Print Products Store in the iPhoto Preferences > Advanced is set to U.K.
    Also the bimmling address, Delivery address, the country for your AppleID and Credit Card must all be in the same country. Check this document:
    http://store.apple.com/uk/help/print_products
    -- Léonie

  • I use an iphone 5 ..my problem is whenevr i set a picture of my contacts in their contacts info..the picture never shows up when they call me..i even added my country code to their no. but it still didnt solve the problem..so wat shud i do now?

    I use an iphone 5 ..my problem is whenevr i set a picture of my contacts in their contacts info..the picture never shows up when they call me..i even added my country code to their no. but it still didnt solve the problem..so wat shud i do now?

    Do you see your contact's number?
    What carrier are you using?

  • Changing/Creating Country Field in Address from ESS

    Friends,
    I am using country version 99 and working on new Implementation of ESS on ECC6.0.
    Can any body help me with the following:
    -  I am not able to Change/Create Country Field in Address from ESS
    I got the solution. I need to do the Following:
    - viekn field in IT0003 ishould not be empty
    - Need to work on report RPUFACEVIEKN and the feature IVWID
    Can any one help me how to do this?
    Thanks in Advance,
    Preethi

    Hi,
    Please check the threads.
    Personnel Information----Tab
    java.lang.NullPointerException
    Re: PC_UI Switch in T77S0 Table and T582G
    PG162 after upgrade
    Re: action  chanage
    Thanks & Regards,
    Sandip

Maybe you are looking for