• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1704
  • Last Modified:

Send a Task Request via PHP mail function

Hey All,
I am looking for a way to send an email from a PHP script using a sime Mail function, but it needs to be sent as a Task Request to Outlook / Exchange. I can successfully have it sent to the correct email address (task.request@myisp.com), but can't for the life of me figure out how to get it into a Task Request (assigned task) format.


Partial current script:

$mailto="janitorial@myisp.com";
$headers = "From: $requestor\r\nReply-To: helpdesk@myisp.com" .
"MIME-Version: 1.0\n" .  
    "Content-type: text/html; charset=iso-8859-1";


mail ($mailto, "Task Janitorial Services", $body, $headers);



Clarification:

My company uses Task Requests created in Outlook to send to various departments, such as Janitorial Services, and tracks those tasks until completed. I have created a form that uses a simple Mail function to send HTML emails to various email addresses, and it works great. However, I now have department leaders requesting forms that can be used to submit Task Requests the same way.

Is there a script someone has that can accomplish this?
0
wrightmed
Asked:
wrightmed
  • 3
1 Solution
 
themrrobertCommented:
Here is a script i just wrote that should make a task.


Now, you should save it to a .vcs file and attach it to your mail message and send it. I'm sure you know how to do that. Also, you should use UTF-8 character code.

<?php

function MakeTask($TaskSubject, $TaskBody) {
$str = "METHOD: REQUEST\n";
$str .= "BEGIN:VCALENDAR\n"
$str =. "PRODID:-//Microsoft Corporation//Outlook \n";
$str .= "MIMEDIR//ENVERSION:1.0\n";
$str .= "BEGIN:VEVENT\n";

$str .= "DTSTART:20091216T163000\n";
$str .= "DTEND:20091216T183000\n";
$str .= "LOCATION;ENCODING=QUOTED-PRINTABLE: \n";
//Body
$str .= "DESCRIPTION;ENCODING=QUOTED-PRINTABLE: "
  $str .= $TaskBody . "\n";
//Subject
$str .= "SUMMARY;ENCODING=QUOTED-PRINTABLE: ";
  $str .= $TaskSubject . "\n";

$str .= "PRIORITY:3\n";
$str .= "END:VEVENT\n";
$str .= "END:VCALENDAR\n";
}




?>

Open in new window

0
 
themrrobertCommented:
I had a script that did it before, but couldn't find it.

This link should help you as well:

http://www.codeproject.com/KB/cs/sendtaskspgmticly.aspx

Contact me if you need more help implementing.
0
 
themrrobertCommented:
oops, my code is bugged! Here ya go - corrected script.

<?php

function MakeTask($TaskSubject, $TaskBody) {
$str = "METHOD: REQUEST\n";
$str .= "BEGIN:VCALENDAR\n"
$str .= "PRODID:-//Microsoft Corporation//Outlook \n";
$str .= "MIMEDIR//ENVERSION:1.0\n";
$str .= "BEGIN:VEVENT\n";

$str .= "DTSTART:20091216T163000\n";
$str .= "DTEND:20091216T183000\n";
$str .= "LOCATION;ENCODING=QUOTED-PRINTABLE: \n";
//Body
$str .= "DESCRIPTION;ENCODING=QUOTED-PRINTABLE: ";
  $str .= $TaskBody . "\n";
//Subject
$str .= "SUMMARY;ENCODING=QUOTED-PRINTABLE: ";
  $str .= $TaskSubject . "\n";

$str .= "PRIORITY:3\n";
$str .= "END:VEVENT\n";
$str .= "END:VCALENDAR\n";
}




?>

Open in new window

0
 
wrightmedAuthor Commented:
I had to do some extra digging, but this gave me the solution I needed. Very good answer.
0
 
rlivelyCommented:
Please see the following post as a followup to that codeproject article - the code given in that project produces an invalid vCalendar/iCalendar file:

broken code - do not use as-is - please read the RFC and validate
http://www.codeproject.com/KB/cs/sendtaskspgmticly.aspx?msg=3429265

Read the RFC at http://tools.ietf.org/html/rfc5545 and use the iCalendar  validator tool available at http://icalvalid.cloudapp.net/ to help create proper iCalendar files (read the full codeproject post for more details).

In particular notice that the PRODID property has a break (\n) in it where it shouldn't, which produces MIMEDIR starting on a line by itself.  This is incorrect, as there is no property named "MIMEDIR," and it should really be a part of the line above it.  

$str .= "PRODID:-//Microsoft Corporation//Outlook \n";
$str .= "MIMEDIR//ENVERSION:1.0\n";
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now