******* If you downloaded a copy of ZimbraSession.pm and it's not working ******* It's because I uploaded a broken copy. Please re-download the file
******* It should be working fine now. Sorry.
Hey all, I don't know if something already exist like this but I wrote a simple Perl module to simplify SOAP communications with the Zimbra server. Basically I just took some of the existing Perl scripts and converted them into methods, and put them in one module. Hopefully this can be of some use to someone. If some one knows of a better module please let me know. Or if you upgrade and make this one better please let me know. I will attach the module, and the crappy example file I made. Below is the example file so you can see how it's used. All the methods are really only for dealing with the Calendar because that's all I need it for. Hopefully someone will add to it and covert the scripts for email's to methods for this module.
This is how to use the module:
#!/usr/bin/perl -w
use lib '/usr/local/src/Zimbra/'; # Holds Soap.pm, Soap11, Soap12 Sudds.., XmlDoc, XmlElement, and ZimbraSession
use ZimbraSession;
################################################## ############
#
# All these methods return the SOAP response from the server.
#
################################################## ############
##############################
# Create New Appointment
##############################
# As an option you can set acctns and mailns. By default they are set to urn:zimbraAccount and urn:zimbraMail respectively.
my $zs = ZimbraSession->new(
{name => 'Display Name', login => 'username'},
'password',
'http://yourhost.net/service/soap/',
# {acctns => '', mailns => ''}
);
my $attendees = [
{name => 'Matt Foley', email => 'mfoley@email.com'},
{name => 'Bill Brasky', email => 'bbrasky@email.com'}
]; # List of attendees to invite to an appointment
# For now this will only set an appointment in your default Calendar.
# These are not recurring appointmetns like the createAppt.pl script
my $appointment = $zs->createAppt(
'Subject', 'Location',
'', # Show as
'', # Calendar
'Start Time',
'End Time',
'', # Recuring
$attendees,
'Plain Text Message',
"HTML Message",
''
);
#####################
# Cancel Appointment
#####################
my $cancel_appointment = $zs->cancelAppt($invId, $subject, $message, $attendees);
###########################
# Retrieve an Appointment
###########################
my $appointment = $zs->getAppt($apptId);
##################################
# Retrieve Appointment Summaries
##################################
my $summaries = $zs->getApptSummaries($start_time, $end_time);
##################################
# Modify an Appointment
##################################
my $modified_appt = $zs->modifyAppt(
$invId, $mode, $end_time,
$subject, $message, $location,
$current_attendees, $new_attendees
);
##################################
# Create Folder
##################################
# Right now I believe this only creates Calendars, because that's all I needed, but it can easily be modifed to
# create folders. You just need to figure out the correct 'view' and edit it the method.
my $folder = $zs->createFolder($folder_name);
##################################
# Delete Folder
##################################
# I dont think you can use the folder name here.
# The folder id is returned in the respone from createFolder();
my $deleted_folder = $zs->deleteFolder($folder_id);


LinkBack URL
About LinkBacks





