Login   Register  
PHP Classes
elePHPant
Icontem

File: conv_maillist.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of CPK Smithies  >  IMC Objects 2  >  conv_maillist.php  >  Download  
File: conv_maillist.php
Role: Example script
Content type: text/plain
Description: Example program to convert MS Outlook mailing list .txt files into Evolution-compatible vCards
Class: IMC Objects 2
Parse and generate vCard and iCalendar files
Author: By
Last change:
Date: 3 years ago
Size: 889 bytes
 

Contents

Class file image Download
<?php
/**
 * Convert mailing-list from text to vcf
 * @author CPKS
 * @package imc
 */
require 'evolution_maillist.php';
require 
'outlook_ml.php';

// MAIN

if ($argc 2)
  die(
"No arguments on the command line.\n");
array_shift($argv); // get rid of script name
$errs 0;

while (
$arg array_shift($argv)) {
  if (!
is_readable($arg)) {
    echo 
"Cannot read $arg\n";
    ++
$errs;
    continue;
  }
  try {
    
$input = new imc\outlook\data($arg);
  }
  catch (
Exception $e) {
    echo 
$e->getMessage() . PHP_EOL;
    ++
$errs;
    continue;
  }
  
$listname $input->title;
  
$fn pathinfo($argPATHINFO_FILENAME) . '.vcf';
  
$ml = new imc\evolution\EmailList($listname$input->categories);
  foreach (
$input as $line)
    
$ml->add_email($line);
  
$ml->writeFile($fn);
  echo 
"$arg converted to $fn\n";
}
echo 
"Completed with $errs errors.\n";