TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   New php challenge (http://www.talkphp.com/general/2088-new-php-challenge.html)

sarmenhb 01-25-2008 02:35 AM

New php challenge
 
this might be a little advanced but the challenge is to create a php script that will take user input kind of like a tasks page and when the submit button is pressed that data will be sent to outlook and be displayed in the tasks pane

if your a linux user use whatever you use for your email client

the winner gets a beer with a hot girl.

Orc 01-25-2008 02:41 AM

SQL is your friend, though I'm just saying that cause I don't feel like writing some code down right now.

Alan @ CIT 01-25-2008 11:16 AM

I'm gonna skip this one since I've written more tools to connect to Outlook than I can remember so it wouldn't be fair, but I'll give everyone else one little word to help them along: Com :-)

Alan

Alan @ CIT 01-27-2008 02:18 PM

Ok, since no-one else entered I might as well post my code :) It doesn't take user input purely because I'm too lazy to make a form, but you get the idea :-D

PHP Code:

<?php
/**
 * Generates a new task and adds it to Outlook
 * This PHP script must be run on the same machine as Outlook for it to work
 */

// Connect to Outlook using the Com interface
try
{
    
$comOutlook = new Com('Outlook.Application');
}
catch (
Exception $e)
{
    die(
'Unable to connect to Outlook: ' $e->getMessage());
}

// Create the new task
try
{
    
$newTask $comOutlook->CreateItem(3);

    
// Task details - full list of properties: http://msdn2.microsoft.com/en-us/library/bb177256.aspx
    
$newTask->Subject 'Visit TalkPHP';
    
$newTask->Body 'Do not forget to visit TalkPHP today!';
    
$newTask->DueDate '01/28/08';

    
// Save the new task
    
$newTask->Save();
    echo 
'Task Added';
}
catch (
Exception $e)
{
    die(
'Unable to create new task: ' $e->getMessage());
}

Screenshot of the new task in Outlook: http://i77.photobucket.com/albums/j4...n/outlook1.jpg

Alan

sarmenhb 01-30-2008 03:05 AM

thanks for the code but when i try to compile it my browser crashes. am i missing anything?

Orc 01-30-2008 03:42 AM

Quote:

Originally Posted by Alan @ CIT (Post 9772)
Ok, since no-one else entered I might as well post my code :) It doesn't take user input purely because I'm too lazy to make a form, but you get the idea :-D

PHP Code:

<?php
/**
 * Generates a new task and adds it to Outlook
 * This PHP script must be run on the same machine as Outlook for it to work
 */

// Connect to Outlook using the Com interface
try
{
    
$comOutlook = new Com('Outlook.Application');
}
catch (
Exception $e)
{
    die(
'Unable to connect to Outlook: ' $e->getMessage());
}

// Create the new task
try
{
    
$newTask $comOutlook->CreateItem(3);

    
// Task details - full list of properties: http://msdn2.microsoft.com/en-us/library/bb177256.aspx
    
$newTask->Subject 'Visit TalkPHP';
    
$newTask->Body 'Do not forget to visit TalkPHP today!';
    
$newTask->DueDate '01/28/08';

    
// Save the new task
    
$newTask->Save();
    echo 
'Task Added';
}
catch (
Exception $e)
{
    die(
'Unable to create new task: ' $e->getMessage());
}

Screenshot of the new task in Outlook: http://i77.photobucket.com/albums/j4...n/outlook1.jpg

Alan

That'll only work on Windows, :<

sarmenhb 01-30-2008 07:10 AM

Quote:

Originally Posted by Orc (Post 9932)
That'll only work on Windows, :<

i am using windows xp, and i got outlook 2007, is there a setting i gotta set in registry or something like that?

Alan @ CIT 01-30-2008 08:03 AM

Orc: I only use Windows so it's all good :-D

Sarmenhb: What web browser are you using, are you using a full copy of Outlook or Outlook Express, and is Outlook open when you run the script?

Alan


All times are GMT. The time now is 11:27 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0