How does one create a set of distribution (email lists). I'm looking
to set up a number of different lists.. .for say freshman,
sophomores....etc...
How can I accomplish this?
> How does one create a set of distribution (email lists). I'm looking
> to set up a number of different lists.. .for say freshman,
> sophomores....etc...
> How can I accomplish this?
> Thanks
> Ralph Fasano
> RISD
> "just a beginner"
Distribution lists are also important for my school. When looking at
the documentation, it seems that I would need to add each person
manually, one-by-one. Is this correct? Is there a way to important a
csv list of a hundred users at once? There really needs to be this
option! Thanks.
Ariel
"not yet converted"
On May 28, 6:05 am, techlover <2silverp...@gmail.com> wrote:
> On May 27, 10:43 am, Ralph <rfas...@g.risd.edu> wrote:
> > How does one create a set of distribution (email lists). I'm looking
> > to set up a number of different lists.. .for say freshman,
> > sophomores....etc...
> > How can I accomplish this?
> > Thanks
> > Ralph Fasano
> > RISD
> > "just a beginner"- Hide quoted text -
With GApps APIs (Education and Premier Editions), you can use the
Provisioning APIs to do all operations on email lists, e.g. created,
add users, delete users, etc. Although mosts operations deal with one
list or one email address at a time, the APIs can be used in loops to
do bulk updates. See the following Help page for more about APIs and
email lists. This particular example is in java, but php libraries are
also available.
http://code.google.com/apis/apps/gdata_provisioning_api_v2.0_referenc...
> Distribution lists are also important for my school. When looking at
> the documentation, it seems that I would need to add each person
> manually, one-by-one. Is this correct? Is there a way to important a
> csv list of a hundred users at once? There really needs to be this
> option! Thanks.
> Ariel
> "not yet converted"
> On May 28, 6:05 am,techlover<2silverp...@gmail.com> wrote:
> > On May 27, 10:43 am, Ralph <rfas...@g.risd.edu> wrote:
> > > How does one create a set of distribution (email lists). I'm looking
> > > to set up a number of different lists.. .for say freshman,
> > > sophomores....etc...
> > > How can I accomplish this?
> > > Thanks
> > > Ralph Fasano
> > > RISD
> > > "just a beginner"- Hide quoted text -
I'm new to Google Apps Educational Version too and we also rely on
email lists heavily. I've been looking into the API's and I'm not
able to find help in getting started either other than being told
where the code is. I guess one has to be pretty proficient in
programming to make sense of it all. If you find a solution I'd be
grateful if you'd share it with me.
Marty Wild
On Jun 4, 12:31 pm, Ariel <lionof...@gmail.com> wrote:
> Distribution lists are also important for my school. When looking at
> the documentation, it seems that I would need to add each person
> manually, one-by-one. Is this correct? Is there a way to important a
> csv list of a hundred users at once? There really needs to be this
> option! Thanks.
> Ariel
> "not yet converted"
> On May 28, 6:05 am, techlover <2silverp...@gmail.com> wrote:
> > On May 27, 10:43 am, Ralph <rfas...@g.risd.edu> wrote:
> > > How does one create a set of distribution (email lists). I'm looking
> > > to set up a number of different lists.. .for say freshman,
> > > sophomores....etc...
> > > How can I accomplish this?
> > > Thanks
> > > Ralph Fasano
> > > RISD
> > > "just a beginner"- Hide quoted text -
I'm with Marty. I don't do the programming around here, but even my
guy who does is not familar with all this API stuff and is having
trouble finding the "first step" on the pages you linked. Is there a
Google Labs app that will do the email lists, so we dont' have to
write our own code? Please help. Thanks.
Ariel
On Jun 9, 8:19 am, martyw <mw...@mogschool.com> wrote:
> I'm new to Google Apps Educational Version too and we also rely on
> email lists heavily. I've been looking into the API's and I'm not
> able to find help in getting started either other than being told
> where the code is. I guess one has to be pretty proficient in
> programming to make sense of it all. If you find a solution I'd be
> grateful if you'd share it with me.
> Marty Wild
> On Jun 4, 12:31 pm, Ariel <lionof...@gmail.com> wrote:
> > Larry,
> > Distribution lists are also important for my school. When looking at
> > the documentation, it seems that I would need to add each person
> > manually, one-by-one. Is this correct? Is there a way to important a
> > csv list of a hundred users at once? There really needs to be this
> > option! Thanks.
> > Ariel
> > "not yet converted"
> > On May 28, 6:05 am, techlover <2silverp...@gmail.com> wrote:
> > > On May 27, 10:43 am, Ralph <rfas...@g.risd.edu> wrote:
> > > > How does one create a set of distribution (email lists). I'm looking
> > > > to set up a number of different lists.. .for say freshman,
> > > > sophomores....etc...
> > > > How can I accomplish this?
> > > > Thanks
> > > > Ralph Fasano
> > > > RISD
> > > > "just a beginner"- Hide quoted text -
I feel your pain, so I wrote you a script which uploads mailing list
data from csv files. If you can get your mailing list content into the
right format csv, you should be set. Copy and paste the source below
into a file called 'misterlist.py', then follow the instructions in
the script.
#!/usr/bin/python2.5
#
# Copyright 2008 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0 #
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
instructions:
0) activate the provisioning API for your domain here
https://www.google.com/a/cpanel/<yourdomainhere.com>/Users
1) get python 2.4 or 2.5 from http://python.org/download/ and install
it
2) get the gdata python library from http://code.google.com/p/gdata-python-client/downloads/list 3) extract the library and place the 'atom' and 'gdata' source
directories in the same directory as this script
4) specify a list csv of format
listname (not list email address), user email address
e.g.
"""
results = {}
f = open(filename)
while True:
line = f.readline()
if not line:
break
listname, user = line.strip().split(",")
userlist = []
if not results.has_key(listname):
userlist = [ user ]
results[listname] = userlist
else:
userlist = results[listname]
userlist.append(user)
logging.debug(results)
return results
def upload_list_data(data, username, password, domain):
try:
service = AppsService(domain = domain)
service.ClientLogin(username = username, password = password)
for list in data.keys():
addlist = data[list]
#create list
logging.debug("trying to creating list " + list)
existing_list = None
try:
existing_list = service.RetrieveEmailList(list)
except Error:
pass
if existing_list:
print "list " + list + " already exists, updating..."
else:
service.CreateEmailList(list)
logging.debug("created list " + list)
# add users
for user in addlist:
logging.debug("creating user " + user)
service.AddRecipientToEmailList(user, list)
except AppsForYourDomainException, e:
print e
def main(argv):
logging.debug(argv)
try:
opts, args = getopt.getopt(argv, "f:u:p:")
except getopt.GetoptError:
sys.exit(2)
filename = None
username = None
password = None
for o, a in opts:
if o == "-f":
filename = a
elif o == "-u":
username = a
elif o == "-p":
password = a
else:
print "unhandled option " + o
> I'm with Marty. I don't do the programming around here, but even my
> guy who does is not familar with all this API stuff and is having
> trouble finding the "first step" on the pages you linked. Is there a
> Google Labs app that will do the email lists, so we dont' have to
> write our own code? Please help. Thanks.
> Ariel
> On Jun 9, 8:19 am, martyw <mw...@mogschool.com> wrote:
> > Larry,
> > I'm new to Google Apps Educational Version too and we also rely on
> > email lists heavily. I've been looking into the API's and I'm not
> > able to find help in getting started either other than being told
> > where the code is. I guess one has to be pretty proficient in
> > programming to make sense of it all. If you find a solution I'd be
> > grateful if you'd share it with me.
> > Marty Wild
> > On Jun 4, 12:31 pm, Ariel <lionof...@gmail.com> wrote:
> > > Larry,
> > >Distributionlists are also important for my school. When looking at
> > > the documentation, it seems that I would need to add each person
> > > manually, one-by-one. Is this correct? Is there a way to important a
> > > csv list of a hundred users at once? There really needs to be this
> > > option! Thanks.
> > > Ariel
> > > "not yet converted"
> > > On May 28, 6:05 am, techlover <2silverp...@gmail.com> wrote:
> > > > On May 27, 10:43 am, Ralph <rfas...@g.risd.edu> wrote:
> > > > > How does one create a set ofdistribution(email lists). I'm looking
> > > > > to set up a number of different lists.. .for say freshman,
> > > > > sophomores....etc...
> > > > > How can I accomplish this?
Thank you Gabe that has saved me countless hours - and given me a
chance to learn how to run python scripts - thank you!
A few gotchas that I overcame:
1. Had to remove an odd line break from line 13 so it reads in full,
(no break before implied)
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
2. Email list should be created first (otherwise I got errors, from
lines 133, 19 & 91) - might just be me?
3. MS Excel saved csv with " around text values - boo hiss! - check
and remove in text editor if necessary.
4. Worked on PC, but when using an eeePC (they're great!) 900 - had to
run script using python2.5 instead of python (eee has python 2.5
installed but defaults to running python 2.4 minimal version instead)
- so change first word of command from python to python2.5
Those problems might just have been me, but it might help someone out
there.
You shouldn't have to create the lists first... Can you post the full
error information you're seeing? I'll try and reproduce myself and
share an update.
On Jun 12, 3:07 pm, ChrisRyall <ch...@ryall.info> wrote:
> Thank you Gabe that has saved me countless hours - and given me a
> chance to learn how to run python scripts - thank you!
> A few gotchas that I overcame:
> 1. Had to remove an odd line break from line 13 so it reads in full,
> (no break before implied)
> # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> 2. Email list should be created first (otherwise I got errors, from
> lines 133, 19 & 91) - might just be me?
> 3. MS Excel saved csv with " around text values - boo hiss! - check
> and remove in text editor if necessary.
> 4. Worked on PC, but when using an eeePC (they're great!) 900 - had to
> run script using python2.5 instead of python (eee has python 2.5
> installed but defaults to running python 2.4 minimal version instead)
> - so change first word of command from python to python2.5
> Those problems might just have been me, but it might help someone out
> there.
whoops, replace the word Error with Exception in my code, and it
solves the uncreated list problem:
#!/usr/bin/python2.5
#
# Copyright 2008 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0 #
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
instructions:
0) activate the provisioning API for your domain here
https://www.google.com/a/cpanel/<yourdomainhere.com>/Users
1) get python 2.4 or 2.5 from http://python.org/download/ and install
it
2) get the gdata python library from http://code.google.com/p/gdata-python-client/downloads/list 3) extract the library and place the 'atom' and 'gdata' source
directories in the same directory as this script
4) specify a list csv of format
listname (not list email address), user email address
e.g.
"""
results = {}
f = open(filename)
while True:
line = f.readline()
if not line:
break
listname, user = line.strip().split(",")
userlist = []
if not results.has_key(listname):
userlist = [ user ]
results[listname] = userlist
else:
userlist = results[listname]
userlist.append(user)
logging.debug(results)
return results
def upload_list_data(data, username, password, domain):
try:
service = AppsService(domain = domain)
service.ClientLogin(username = username, password = password)
for list in data.keys():
addlist = data[list]
#create list
logging.debug("trying to creating list " + list)
existing_list = None
try:
existing_list = service.RetrieveEmailList(list)
except Exception:
pass
if existing_list:
print "list " + list + " already exists, updating..."
else:
service.CreateEmailList(list)
logging.debug("created list " + list)
# add users
for user in addlist:
logging.debug("creating user " + user)
service.AddRecipientToEmailList(user, list)
except AppsForYourDomainException, e:
print e
def main(argv):
logging.debug(argv)
try:
opts, args = getopt.getopt(argv, "f:u:p:")
except getopt.GetoptError:
sys.exit(2)
filename = None
username = None
password = None
for o, a in opts:
if o == "-f":
filename = a
elif o == "-u":
username = a
elif o == "-p":
password = a
else:
print "unhandled option " + o
> You shouldn't have to create the lists first... Can you post the full
> error information you're seeing? I'll try and reproduce myself and
> share an update.
> On Jun 12, 3:07 pm, ChrisRyall <ch...@ryall.info> wrote:
> > Thank you Gabe that has saved me countless hours - and given me a
> > chance to learn how to run python scripts - thank you!
> > A few gotchas that I overcame:
> > 1. Had to remove an odd line break from line 13 so it reads in full,
> > (no break before implied)
> > # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > implied.
> > 2. Email list should be created first (otherwise I got errors, from
> > lines 133, 19 & 91) - might just be me?
> > 3. MS Excel saved csv with " around text values - boo hiss! - check
> > and remove in text editor if necessary.
> > 4. Worked on PC, but when using an eeePC (they're great!) 900 - had to
> > run script using python2.5 instead of python (eee has python 2.5
> > installed but defaults to running python 2.4 minimal version instead)
> > - so change first word of command from python to python2.5
> > Those problems might just have been me, but it might help someone out
> > there.
C:\Documents and Settings\MPlotsker\Desktop\gdata.py-1.1.0\src>python
misterlist
.py -f grade9.csv -u mplots...@mdyhs.net -p password
Traceback (most recent call last):
File "misterlist.py", line 42, in ?
from gdata.apps.service import AppsService
File "C:\Documents and Settings\MPlotsker\Desktop\gdata.py-1.1.0\src
\gdata\__i
nit__.py", line 27, in ?
import atom
File "C:\Documents and Settings\MPlotsker\Desktop\gdata.py-1.1.0\src
\atom\__in
it__.py", line 56, in ?
from elementtree import ElementTree
ImportError: No module named elementtree
On Jun 12, 7:24 pm, Gabe Cohen <gaco...@gmail.com> wrote:
> whoops, replace the word Error with Exception in my code, and it
> solves the uncreated list problem:
> #!/usr/bin/python2.5
> #
> # Copyright 2008 Google Inc.
> #
> # Licensed under the Apache License, Version 2.0 (the "License");
> # you may not use this file except in compliance with the License.
> # You may obtain a copy of the License at
> #
> # http://www.apache.org/licenses/LICENSE-2.0 > #
> # Unless required by applicable law or agreed to in writing, software
> # distributed under the License is distributed on an "AS IS" BASIS,
> # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> # See the License for the specific language governing permissions and
> # limitations under the License.
> """
> instructions:
> 0) activate the provisioning API for your domain herehttps://www.google.com/a/cpanel/<yourdomainhere.com>/Users
> 1) get python 2.4 or 2.5 fromhttp://python.org/download/and install
> it
> 2) get the gdata python library fromhttp://code.google.com/p/gdata-python-client/downloads/list > 3) extract the library and place the 'atom' and 'gdata' source
> directories in the same directory as this script
> 4) specify a list csv of format
> listname (not list email address), user email address
> e.g.
> On Jun 12, 4:19 pm, Gabe Cohen <gaco...@gmail.com> wrote:
> > Hi Chris,
> > You shouldn't have to create the lists first... Can you post the full
> > error information you're seeing? I'll try and reproduce myself and
> > share an update.
> > On Jun 12, 3:07 pm, ChrisRyall <ch...@ryall.info> wrote:
> > > Thank you Gabe that has saved me countless hours - and given me a
> > > chance to learn how to run python scripts - thank you!
> > > A few gotchas that I overcame:
> > > 1. Had to remove an odd line break from line 13 so it reads in full,
> > > (no break before implied)
> > > # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > > implied.
> > > 2. Email list should be created first (otherwise I got errors, from
> > > lines 133, 19 & 91) - might just be me?
> > > 3. MS Excel saved csv with " around text values - boo hiss! - check
> > > and remove in text editor if necessary.
> > > 4. Worked on PC, but when using an eeePC (they're great!) 900 - had to
> > > run script using python2.5 instead of python (eee has python 2.5
> > > installed but defaults to running python 2.4 minimal version instead)
> > > - so change first word of command from python to python2.5
> > > Those problems might just have been me, but it might help someone out
> > > there.
was using activepython 4. uninstalled that. now using python2.5.
still getting these errors
thanks
michael
C:\Python25>python misterlist.py -f grade9.csv -u mplots...@mdyhs.net -
p password
Traceback (most recent call last):
File "misterlist.py", line 132, in <module>
main(sys.argv[1:])
File "misterlist.py", line 125, in main
results = parse_csv(filename.strip())
File "misterlist.py", line 66, in parse_csv
listname, user = line.strip().split(",")
ValueError: too many values to unpack
On Jun 13, 12:08 am, "mplots...@gmail.com" <mplots...@gmail.com>
wrote:
> C:\Documents and Settings\MPlotsker\Desktop\gdata.py-1.1.0\src>python
> misterlist
> .py -f grade9.csv -u mplots...@mdyhs.net -p password
> Traceback (most recent call last):
> File "misterlist.py", line 42, in ?
> from gdata.apps.service import AppsService
> File "C:\Documents and Settings\MPlotsker\Desktop\gdata.py-1.1.0\src
> \gdata\__i
> nit__.py", line 27, in ?
> import atom
> File "C:\Documents and Settings\MPlotsker\Desktop\gdata.py-1.1.0\src
> \atom\__in
> it__.py", line 56, in ?
> from elementtree import ElementTree
> ImportError: No module named elementtree
> On Jun 12, 7:24 pm, Gabe Cohen <gaco...@gmail.com> wrote:
> > whoops, replace the word Error with Exception in my code, and it
> > solves the uncreated list problem:
> > #!/usr/bin/python2.5
> > #
> > # Copyright 2008 Google Inc.
> > #
> > # Licensed under the Apache License, Version 2.0 (the "License");
> > # you may not use this file except in compliance with the License.
> > # You may obtain a copy of the License at
> > #
> > # http://www.apache.org/licenses/LICENSE-2.0 > > #
> > # Unless required by applicable law or agreed to in writing, software
> > # distributed under the License is distributed on an "AS IS" BASIS,
> > # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > implied.
> > # See the License for the specific language governing permissions and
> > # limitations under the License.
> > """
> > instructions:
> > 0) activate the provisioning API for your domain herehttps://www.google.com/a/cpanel/<yourdomainhere.com>/Users
> > 1) get python 2.4 or 2.5 fromhttp://python.org/download/andinstall > > it
> > 2) get the gdata python library fromhttp://code.google.com/p/gdata-python-client/downloads/list > > 3) extract the library and place the 'atom' and 'gdata' source
> > directories in the same directory as this script
> > 4) specify a list csv of format
> > listname (not list email address), user email address
> > e.g.
> > if __name__ == "__main__":
> > main(sys.argv[1:])
> > On Jun 12, 4:19 pm, Gabe Cohen <gaco...@gmail.com> wrote:
> > > Hi Chris,
> > > You shouldn't have to create the lists first... Can you post the full
> > > error information you're seeing? I'll try and reproduce myself and
> > > share an update.
> > > On Jun 12, 3:07 pm, ChrisRyall <ch...@ryall.info> wrote:
> > > > Thank you Gabe that has saved me countless hours - and given me a
> > > > chance to learn how to run python scripts - thank you!
> > > > A few gotchas that I overcame:
> > > > 1. Had to remove an odd line break from line 13 so it reads in full,
> > > > (no break before implied)
> > > > # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > > > implied.
> > > > 2. Email list should be created first (otherwise I got errors, from
> > > > lines 133, 19 & 91) - might just be me?
> > > > 3. MS Excel saved csv with " around text values - boo hiss! - check
> > > > and remove in text editor if necessary.
> > > > 4. Worked on PC, but when using an eeePC (they're great!) 900 - had to
> > > > run script using python2.5 instead of python (eee has python 2.5
> > > > installed but defaults to running python 2.4 minimal version instead)
> > > > - so change first word of command from python to python2.5
> > > > Those problems might just have been me, but it might help someone out
> > > > there.
> was using activepython 4. uninstalled that. now using python2.5.
> still getting these errors
> thanks
> michael
> C:\Python25>python misterlist.py -f grade9.csv -u mplots...@mdyhs.net -
> p password
> Traceback (most recent call last):
> File "misterlist.py", line 132, in <module>
> main(sys.argv[1:])
> File "misterlist.py", line 125, in main
> results = parse_csv(filename.strip())
> File "misterlist.py", line 66, in parse_csv
> listname, user = line.strip().split(",")
> ValueError: too many values to unpack
> On Jun 13, 12:08 am, "mplots...@gmail.com" <mplots...@gmail.com>
> wrote:
> > help. i am getting the following errors.
> > C:\Documents and Settings\MPlotsker\Desktop\gdata.py-1.1.0\src>python
> > misterlist
> > .py -f grade9.csv -u mplots...@mdyhs.net -p password
> > Traceback (most recent call last):
> > File "misterlist.py", line 42, in ?
> > from gdata.apps.service import AppsService
> > File "C:\Documents and Settings\MPlotsker\Desktop\gdata.py-1.1.0\src
> > \gdata\__i
> > nit__.py", line 27, in ?
> > import atom
> > File "C:\Documents and Settings\MPlotsker\Desktop\gdata.py-1.1.0\src
> > \atom\__in
> > it__.py", line 56, in ?
> > from elementtree import ElementTree
> > ImportError: No module named elementtree
> > On Jun 12, 7:24 pm, Gabe Cohen <gaco...@gmail.com> wrote:
> > > whoops, replace the word Error with Exception in my code, and it
> > > solves the uncreated list problem:
> > > #!/usr/bin/python2.5
> > > #
> > > # Copyright 2008 Google Inc.
> > > #
> > > # Licensed under the Apache License, Version 2.0 (the "License");
> > > # you may not use this file except in compliance with the License.
> > > # You may obtain a copy of the License at
> > > #
> > > # http://www.apache.org/licenses/LICENSE-2.0 > > > #
> > > # Unless required by applicable law or agreed to in writing, software
> > > # distributed under the License is distributed on an "AS IS" BASIS,
> > > # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > > implied.
> > > # See the License for the specific language governing permissions and
> > > # limitations under the License.
> > > """
> > > instructions:
> > > 0) activate the provisioning API for your domain herehttps://www.google.com/a/cpanel/<yourdomainhere.com>/Users
> > > 1) get python 2.4 or 2.5 fromhttp://python.org/download/andinstall > > > it
> > > 2) get the gdata python library fromhttp://code.google.com/p/gdata-python-client/downloads/list > > > 3) extract the library and place the 'atom' and 'gdata' source
> > > directories in the same directory as this script
> > > 4) specify a list csv of format
> > > listname (not list email address), user email address
> > > e.g.
> > > On Jun 12, 4:19 pm, Gabe Cohen <gaco...@gmail.com> wrote:
> > > > Hi Chris,
> > > > You shouldn't have to create the lists first... Can you post the full
> > > > error information you're seeing? I'll try and reproduce myself and
> > > > share an update.
> > > > On Jun 12, 3:07 pm, ChrisRyall <ch...@ryall.info> wrote:
> > > > > Thank you Gabe that has saved me countless hours - and given me a
> > > > > chance to learn how to run python scripts - thank you!
> > > > > A few gotchas that I overcame:
> > > > > 1. Had to remove an odd line break from line 13 so it reads in full,
> > > > > (no break before implied)
> > > > > # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > > > > implied.
> > > > > 2. Email list should be created first (otherwise I got errors, from
> > > > > lines 133, 19 & 91) - might just be me?
> > > > > 3. MS Excel saved csv with " around text values - boo hiss! - check
> > > > > and remove in text editor if necessary.
> > > > > 4. Worked on PC, but when using an eeePC (they're great!) 900 - had to
> > > > > run script using python2.5 instead of python (eee has python 2.5
> > > > > installed but defaults to running python 2.4 minimal version instead)
> > > > > - so change first word of command from python to python2.5
> > > > > Those problems might just have been me, but it might help someone out
> > > > > there.
I just wanted to say thanks Gabe. My programmer is starting to figure
this stuff out because of your help, though he is just starting to
learn python.
We are now trying to figure out how to import personal distribution
lists into gmail address "groups" for people from their old Pegasus
accounts. If you have any tips for that (or how to only allow certain
people to send to the global mailing lists), let me know. Thanks!
Ariel
On Jun 12, 6:24 pm, Gabe Cohen <gaco...@gmail.com> wrote:
> whoops, replace the word Error with Exception in my code, and it
> solves the uncreated list problem:
> #!/usr/bin/python2.5
> #
> # Copyright 2008 Google Inc.
> #
> # Licensed under the Apache License, Version 2.0 (the "License");
> # you may not use this file except in compliance with the License.
> # You may obtain a copy of the License at
> #
> # http://www.apache.org/licenses/LICENSE-2.0 > #
> # Unless required by applicable law or agreed to in writing, software
> # distributed under the License is distributed on an "AS IS" BASIS,
> # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> # See the License for the specific language governing permissions and
> # limitations under the License.
> """
> instructions:
> 0) activate the provisioning API for your domain herehttps://www.google.com/a/cpanel/<yourdomainhere.com>/Users
> 1) get python 2.4 or 2.5 fromhttp://python.org/download/and install
> it
> 2) get the gdata python library fromhttp://code.google.com/p/gdata-python-client/downloads/list > 3) extract the library and place the 'atom' and 'gdata' source
> directories in the same directory as this script
> 4) specify a list csv of format
> listname (not list email address), user email address
> e.g.
> On Jun 12, 4:19 pm, Gabe Cohen <gaco...@gmail.com> wrote:
> > Hi Chris,
> > You shouldn't have to create the lists first... Can you post the full
> > error information you're seeing? I'll try and reproduce myself and
> > share an update.
> > On Jun 12, 3:07 pm, ChrisRyall <ch...@ryall.info> wrote:
> > > Thank you Gabe that has saved me countless hours - and given me a
> > > chance to learn how to run python scripts - thank you!
> > > A few gotchas that I overcame:
> > > 1. Had to remove an odd line break from line 13 so it reads in full,
> > > (no break before implied)
> > > # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > > implied.
> > > 2. Email list should be created first (otherwise I got errors, from
> > > lines 133, 19 & 91) - might just be me?
> > > 3. MS Excel saved csv with " around text values - boo hiss! - check
> > > and remove in text editor if necessary.
> > > 4. Worked on PC, but when using an eeePC (they're great!) 900 - had to
> > > run script using python2.5 instead of python (eee has python 2.5
> > > installed but defaults to running python 2.4 minimal version instead)
> > > - so change first word of command from python to python2.5
> > > Those problems might just have been me, but it might help someone out
> > > there.
Gabe, thank you so much for all your help. I am "Ariel's" programmer.
I have never written a line of Python until today. Using a little of
yours and learning some from Google, I have come up with a script
which will import users from a CSV file to a specific account's
Contacts. However, I have not seen anything about how to create
groups, or assign people to groups.
def main(argv):
# handle all the parameters
try:
opts, args = getopt.getopt(argv, "f:u:p:")
except getopt.GetoptError:
sys.exit("Invalid parameters")
for o, a in opts:
if o == "-f":
filename = a
elif o == "-u":
username = a
elif o == "-p":
password = a
else:
print "Ignored parameter " + o
# process the login
try:
gd_client = gdata.contacts.service.ContactsService()
gd_client.email = username
gd_client.password = password
gd_client.source = "faith.edu-contacts-1"
gd_client.ProgrammaticLogin()
print "Logged in"
except Exception:
sys.exit("Error: Could not login")
pass
# read the csv file
# format: name, e-mail, notes
f = open(filename)
while True:
line = f.readline()
if not line:
break
name, email, notes = line.strip().split(",")
From Google's Help Page:
"Email lists are currently limited to 1,000 recipients."
I hope that the limit can be increased.
There are about 1200 students in our school...
> Gabe, thank you so much for all your help. I am "Ariel's" programmer.
> I have never written a line of Python until today. Using a little of
> yours and learning some from Google, I have come up with a script
> which will import users from a CSV file to a specific account's
> Contacts. However, I have not seen anything about how to create
> groups, or assign people to groups.
> for o, a in opts:
> if o == "-f":
> filename = a
> elif o == "-u":
> username = a
> elif o == "-p":
> password = a
> else:
> print "Ignored parameter " + o
> # process the login
> try:
> gd_client = gdata.contacts.service.ContactsService()
> gd_client.email = username
> gd_client.password = password
> gd_client.source = "faith.edu-contacts-1"
> gd_client.ProgrammaticLogin()
> print "Logged in"
> except Exception:
> sys.exit("Error: Could not login")
> pass
> # read the csv file
> # format: name, e-mail, notes
> f = open(filename)
> while True:
> line = f.readline()
> if not line:
> break
> name, email, notes = line.strip().split(",")
Thanks so much for your help! I finally got around to playing with
this today and it works great!
My only question to those reading this post then is how to handle
errors, for instance, I get an exception when a domain user doesn't
exist. How do I report the exception and continue? Anybody written
the code yet and able to share it?
Thanks!
Marty
On Jun 12, 7:24 pm, Gabe Cohen <gaco...@gmail.com> wrote:
> whoops, replace the word Error with Exception in my code, and it
> solves the uncreated list problem:
> #!/usr/bin/python2.5
> #
> # Copyright 2008 Google Inc.
> #
> # Licensed under the Apache License, Version 2.0 (the "License");
> # you may not use this file except in compliance with the License.
> # You may obtain a copy of the License at
> #
> # http://www.apache.org/licenses/LICENSE-2.0 > #
> # Unless required by applicable law or agreed to in writing, software
> # distributed under the License is distributed on an "AS IS" BASIS,
> # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> # See the License for the specific language governing permissions and
> # limitations under the License.
> """
> instructions:
> 0) activate the provisioning API for your domain herehttps://www.google.com/a/cpanel/<yourdomainhere.com>/Users
> 1) get python 2.4 or 2.5 fromhttp://python.org/download/and install
> it
> 2) get the gdata python library fromhttp://code.google.com/p/gdata-python-client/downloads/list > 3) extract the library and place the 'atom' and 'gdata' source
> directories in the same directory as this script
> 4) specify a list csv of format
> listname (not list email address), user email address
> e.g.
> On Jun 12, 4:19 pm, Gabe Cohen <gaco...@gmail.com> wrote:
> > Hi Chris,
> > You shouldn't have to create the lists first... Can you post the full
> > error information you're seeing? I'll try and reproduce myself and
> > share an update.
> > On Jun 12, 3:07 pm, ChrisRyall <ch...@ryall.info> wrote:
> > > Thank you Gabe that has saved me countless hours - and given me a
> > > chance to learn how to run python scripts - thank you!
> > > A few gotchas that I overcame:
> > > 1. Had to remove an odd line break from line 13 so it reads in full,
> > > (no break before implied)
> > > # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > > implied.
> > > 2. Email list should be created first (otherwise I got errors, from
> > > lines 133, 19 & 91) - might just be me?
> > > 3. MS Excel saved csv with " around text values - boo hiss! - check
> > > and remove in text editor if necessary.
> > > 4. Worked on PC, but when using an eeePC (they're great!) 900 - had to
> > > run script using python2.5 instead of python (eee has python 2.5
> > > installed but defaults to running python 2.4 minimal version instead)
> > > - so change first word of command from python to python2.5
> > > Those problems might just have been me, but it might help someone out
> > > there.
Sorry, I wasn't clear in my question.... I meant that I want to add a
domain user to the list but if that user doesn't already exist in the
domain, the script bombs out. Of course, you can add non-domain users
with no problem. What happens is I have a list of 200 or 300 email
addresses, and since the list is large it may have an invalid domain
user address (or two) in it. Basically, I want the script to tell me
if I have any invalid user names it in rather than me having to
manually check each list prior to import. Thanks is advance.
Marty
On Jun 18, 10:55 am, averyp <peejav...@gmail.com> wrote:
I was wondering how your programmer is coming along with these
scripts. Can I contact you off-line (outside this group) about your
development efforts with the APIs?
Marty
mw...@mogschool.com
On Jun 10, 2:41 pm, Ariel <lionof...@gmail.com> wrote:
> I'm with Marty. I don't do the programming around here, but even my
> guy who does is not familar with all this API stuff and is having
> trouble finding the "first step" on the pages you linked. Is there a
> Google Labs app that will do the email lists, so we dont' have to
> write our own code? Please help. Thanks.
> Ariel
> On Jun 9, 8:19 am, martyw <mw...@mogschool.com> wrote:
> > Larry,
> > I'm new to Google Apps Educational Version too and we also rely on
> > email lists heavily. I've been looking into the API's and I'm not
> > able to find help in getting started either other than being told
> > where the code is. I guess one has to be pretty proficient in
> > programming to make sense of it all. If you find a solution I'd be
> > grateful if you'd share it with me.
> > Marty Wild
> > On Jun 4, 12:31 pm, Ariel <lionof...@gmail.com> wrote:
> > > Larry,
> > > Distribution lists are also important for my school. When looking at
> > > the documentation, it seems that I would need to add each person
> > > manually, one-by-one. Is this correct? Is there a way to important a
> > > csv list of a hundred users at once? There really needs to be this
> > > option! Thanks.
> > > Ariel
> > > "not yet converted"
> > > On May 28, 6:05 am, techlover <2silverp...@gmail.com> wrote:
> > > > On May 27, 10:43 am, Ralph <rfas...@g.risd.edu> wrote:
> > > > > How does one create a set of distribution (email lists). I'm looking
> > > > > to set up a number of different lists.. .for say freshman,
> > > > > sophomores....etc...
> > > > > How can I accomplish this?
I understand you now. Yes, we had the same problem as well. To
overcome it, I wrote the script below.
The list is just a simple CSV file with "list,email" format. Then,
just execute it using "list.py -f list.csv -d domain -u admin_email -p
password"
====================
#!/usr/bin/python2.5
from gdata.apps.service import AppsService
from gdata.apps.service import AppsForYourDomainException
import sys
import getopt
# handle all the parameters
try:
opts, args = getopt.getopt(sys.argv[1:], "f:d:u:p:")
except getopt.GetoptError:
sys.exit("Invalid parameters")
for o, a in opts:
if o == "-f":
filename = a
elif o == "-d":
domain = a
elif o == "-u":
username = a
elif o == "-p":
password = a
else:
print "Ignored parameter " + o
# process the login
try:
service = AppsService(domain = domain)
service.ClientLogin(username = username, password = password)
except Exception:
sys.exit("Error: Could not login")
pass
# read the csv file
f = open(filename)
while True:
line = f.readline()
if not line:
break
list, email = line.strip().split(",")
list = list.strip()
email = email.strip()
# create list if it doesn't exist
existing_list = None
try:
existing_list = service.RetrieveEmailList(list)
except Exception:
pass
if not existing_list:
service.CreateEmailList(list)
print "e-mail list \"" + list + "\" created"
# add e-mail to the list
try:
service.AddRecipientToEmailList(email, list)
print email + " added to " + list + " list"
except Exception:
pass
print "Cannot add " + email + " to " + list + " list"
Just a note, we use the api at the user login through our portal
rather than loading list. This way as user logs in to our portal,
changes are made in google apps (eg freshman to sophomore or even
student to employee). This also helps when they change their password
and apps account creation. Currently I'm waiting for moderator
capability to be added to Distribution list, can't really have
students blitzing all employees a message! Also waiting to
incorporate Distribution list within sites and docs, so that we can
utilize sites more effectively (departments, committees, and project
teams).
On Jun 27, 10:54 am, averyp <peejav...@gmail.com> wrote:
> I understand you now. Yes, we had the same problem as well. To
> overcome it, I wrote the script below.
> The list is just a simple CSV file with "list,email" format. Then,
> just execute it using "list.py -f list.csv -d domain -u admin_email -p
> password"
> ====================
> #!/usr/bin/python2.5
> from gdata.apps.service import AppsService
> from gdata.apps.service import AppsForYourDomainException
> import sys
> import getopt
> # handle all the parameters
> try:
> opts, args = getopt.getopt(sys.argv[1:], "f:d:u:p:")
> except getopt.GetoptError:
> sys.exit("Invalid parameters")
> for o, a in opts:
> if o == "-f":
> filename = a
> elif o == "-d":
> domain = a
> elif o == "-u":
> username = a
> elif o == "-p":
> password = a
> else:
> print "Ignored parameter " + o
> # process the login
> try:
> service = AppsService(domain = domain)
> service.ClientLogin(username = username, password = password)
> except Exception:
> sys.exit("Error: Could not login")
> pass
> # read the csv file
> f = open(filename)
> while True:
> line = f.readline()
> if not line:
> break
> list, email = line.strip().split(",")
> list = list.strip()
> email = email.strip()
> # create list if it doesn't exist
> existing_list = None
> try:
> existing_list = service.RetrieveEmailList(list)
> except Exception:
> pass
> if not existing_list:
> service.CreateEmailList(list)
> print "e-mail list \"" + list + "\" created"
> # add e-mail to the list
> try:
> service.AddRecipientToEmailList(email, list)
> print email + " added to " + list + " list"
> except Exception:
> pass
> print "Cannot add " + email + " to " + list + " list"
Thank you for your experience share on these email list scripts.
Unfortunately, when I try each of the two scripts proposed, it makes
two different errors.
1. Gabe Cohen script
It seems to block when it checks the username of the csv line.
***
Importing 1 lists ...
Traceback (most recent call last):
File "C:\dev\misterlist\misterlist.py", line 84, in <module>
main(sys.argv[1:])
File "C:\dev\misterlist\misterlist.py", line 80, in main
(username.strip().split("@"))[1])
File "C:\dev\misterlist\misterlist.py", line 42, in upload_list_data
except Error:
NameError: global name 'Error' is not defined
***
2. averyp script
It seems to block at the Email List creation in gdata service.
***
Traceback (most recent call last):
File "C:\dev\misterlist\list.py", line 52, in <module>
service.CreateEmailList(list)
File "C:\Program Files\Google\google_appengine\misterlist\gdata\apps
\service.py", line 220, in CreateEmailList
raise AppsForYourDomainException(e.args[0])
gdata.apps.service.AppsForYourDomainException: ('status', 'body',
'reason')
***
If you already tried those scripts or understand those errors,
I would be very interrested by your feedback