issues creating account in OS X Mail
issues creating account in OS X Mail
- Subject: issues creating account in OS X Mail
- From: email@hidden
- Date: Tue, 02 Nov 2004 12:00:18 -0600
I'm trying to create a mail account in OS X Mail (X 10.3.5). Starting with the "Create New Mail Account" script supplied in /Library/Scripts/Mail Scripts", I have trimmed it down to use fixed values (for testing purposes at the moment). The pop account gets created in Mail but the password is not set although it is being supplied. It also sets up an SMTP server, it again is able to create it but the password is still empty when I check it in Mail. When I run the original script, I have noticed the password fields for the account and SMTP server are not set either. The Mail dictionary for the password property of the smtp server class says "Can be set, but not read via scripting". Also, the "delete newSMTPServer" fails. Here is my script:
property EMAIL_DOMAIN : "myisp.net"
property POP_SERVER_NAME : "mail.myisp.net"
property SMTP_SERVER_NAME : "smtp.myisp.net"
try
set acctName to "script account"
set emailuser to "script_user"
set emailpswd to "cryptic"
set fullName to "script account"
set emailAddress to emailuser & "@" & EMAIL_DOMAIN
set newAccount to createAccount(acctName, emailuser, emailpswd, emailAddress, fullName)
if newAccount is false then
display dialog "Unable to create mail account" buttons {"OK"} default button 1
return
end if
on error errorMsg number errNum
tell me to display dialog "Error while creating mail account " & ¬
return & errorMsg & " (" & errNum & ")" buttons {"OK"} ¬
default button 1 with icon stop
return
end try
createSMTPServer(newAccount, emailuser, emailpswd)
display dialog "Email account sucessfully created in Mail" buttons {"OK"} default button 1
on createAccount(theAccountName, theUsername, thePassword, theEmailAddresses, theFullName)
tell application "Mail"
try
set theNewAccount to make new pop account ¬
with properties {name:theAccountName, authentication:password, user name:theUsername, server name:POP_SERVER_NAME, password:thePassword, full name:theFullName, email addresses:{theEmailAddresses}}
my logger("Created account: " & theAccountName & ", " & theUsername)
on error errorMsg number errNum
set theNewAccount to false
display dialog "An error occurred while creating pop account:" & ¬
return & errorMsg & "(" & errNum & ")"
end try
end tell
return theNewAccount
end createAccount
on createSMTPServer(theAccount, theUsername, thePassword)
try
set newSMTPServer to false
tell application "Mail"
set newSMTPServer to make new smtp server ¬
with properties {server name:SMTP_SERVER_NAME, account type:pop, authentication:password, user name:theUsername, password:thePassword}
my logger("Created SMTP server")
set smtp server of theAccount to newSMTPServer
end tell
logger("Finished setup of SMTP server")
on error errorMsg number errNum
set theNewAccount to false
display dialog "An error occurred while creating SMTP server:" & ¬
return & errorMsg & " (" & errNum & ")"
if not newSMTPServer is false then
tell application "Mail"
delete newSMTPServer
end tell
end if
end try
end createSMTPServer
on logger(theMsg)
display dialog theMsg buttons {"OK"} default button 1
end logger
_______________________________________________
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