Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How does one save a vcard?



On 3/29/07 4:11 PM,
"applescript-users-bounces+berkowit=email@hidden"
<applescript-users-bounces+berkowit=email@hidden> wrote:

> I've tried everything I can think of, but none of it works.  It
> either creates an error or fails silently.
> 
> Here is one example:
> 
> tell application "Address Book"
> set daName to name of person 1
> tell application "Finder"
> make new file with properties {name:daName & ".vcf"} at folder "Dora"
> set dest to the result as alias
> end tell
> set foo to vcard of person 1
> save foo in dest
> end tell
> 
> I've tried it without creating the file with the Finder.
> 
> -- Michelle


tell application "Address Book"
    set daName to name of person 1
    set vcardData to vcard of person 1
end tell

set dest to (path to home folder as Unicode text) & daName & ".vcf"
set foo to open for access file dest with write permission
set eof foo to 0
write vcardData to num
close access foo


In my case (perhaps because my own default app for .vcf is Entourage, not
Address Book, but I think it will happen in all cases since the default file
type when making a file via 'open for access' is TEXT) - the resulting .vcf
file appears with a text file icon, not an Address Book icon. The file can
be opened in Address Book regardless, and is easily fixable by adding this
to the script:


tell application "Finder"
    set file type of file dest to missing value
    set creator type of file dest to missing value
end tell


When its creator and file types are missing value, the icon defaults to
Address Book's vcard icon.

-- 
Paul Berkowitz


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-users/email@hidden
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >How does one save a vcard? (From: Michelle Steiner <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.