Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Send a Task Request via PHP mail function

Posted on 2009-12-16
5
Medium Priority
?
1,626 Views
Last Modified: 2012-05-08
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
Comment
Question by:wrightmed
  • 3
5 Comments
 
LVL 13

Expert Comment

by:themrrobert
ID: 26068168
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
 
LVL 13

Expert Comment

by:themrrobert
ID: 26068176
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
 
LVL 13

Accepted Solution

by:
themrrobert earned 1500 total points
ID: 26068188
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
 

Author Closing Comment

by:wrightmed
ID: 31666828
I had to do some extra digging, but this gave me the solution I needed. Very good answer.
0
 
LVL 3

Expert Comment

by:rlively
ID: 32834807
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I came across an unsolved Outlook issue and here is my solution.
As a matter of fact, Outlook OST files are of much importance in relation to Exchange mailbox. OST files are independent as they are simply copy of data of a user’s mailbox on Exchange Server. Though, if the server’s status is changed or it is dama…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question