Hi there,

I am trying to send an email using PHP (in Wordpress) that is a calendar request. The calendar request arrives fine however the message body (which should be HTML) is blank.

Below is the code. Any help would be GREATLY appreciated.

Tania
Code:
-------------------------------------
//$firstname is the first name of target
//$lastname is the last name of target
//$email is the targets email address
//$meeting_date is straight from a DATETIME mysql field and assumes UTC.
//$meeting_name is the name of your meeting
//$meeting_duration is the duration of your meeting in seconds (3600 = 1 hour)
//$message_body is the body of the message.
 
function sendIcalEmail($firstname,$lastname,$email,$subject,$meeting_date,$meeting_name,$meeting_duration,$me  ssage_body,$attachments = "") {

	$meetingstamp = STRTOTIME($meeting_date . " UTC");    
	$dtstart= GMDATE("Ymd\THis\Z",$meetingstamp);
	$dtend= GMDATE("Ymd\THis\Z",$meetingstamp+$meeting_duration);
	$todaystamp = GMDATE("Ymd\THis\Z");
	$from_name = "My Company";
	$from_address = "company@domain.com.au";
 	
	
	$meeting_description = $message_body."\n\n";
	$meeting_location = "My Office"; //Where will your meeting take place
 
 
	//Convert MYSQL datetime and construct iCal start, end and issue dates
	$meetingstamp = STRTOTIME($meeting_date . " UTC");    
	$dtstart= GMDATE("Ymd\THis\Z",$meetingstamp);
	$dtend= GMDATE("Ymd\THis\Z",$meetingstamp+$meeting_duration);
	$todaystamp = GMDATE("Ymd\THis\Z");
 
	//Create unique identifier
	$cal_uid = DATE('Ymd').'T'.DATE('His')."-".RAND()."@quattrocatering.com.au";
 
	//Create Mime Boundry
	$mime_boundary = "----Meeting Booking----".MD5(TIME());

/*Setting the header part, this is important */

 
	//Create Email Headers
	$headers = "From: ".$from_name." <".$from_address.">\n";
	$headers .= "Reply-To: ".$from_name." <".$from_address.">\n";
 
	$headers .= "MIME-Version: 1.0\n";
	$headers .= "Content-Type: text/calendar;\nmethod=REQUEST;\n";  
	$headers .= '        charset="UTF-8"';				
	$headers .= "\n";						
	$headers .= "Content-Transfer-Encoding: 7bit";	

	//Create Email Body (HTML)
	$message = "--$mime_boundary\r\n";
	$message .= "Content-Type: text/html; charset=UTF-8\n";
	$message .= "Content-Transfer-Encoding: 8bit\n\n";
	$message .= "<html>\n";
	$message .= "<body>\n";
	$message .= '<p>Dear '.$to_name.',</p>';
	$message .= '<p>'.$description.'</p>';
	$message .= "</body>\n";
	$message .= "</html>\n";
	$message .= "--$mime_boundary\r\n";
 
	//Create ICAL Content (Google rfc 2445 for details and examples of usage) 
	$ical =    'BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN
VERSION:2.0
METHOD:REQUEST
BEGIN:VEVENT
STATUS:NEEDS ACTION
EXPECT: IMMEDIATE
ORGANIZER:MAILTO:'.$from_address.'
DTSTART:'.$dtstart.'
DTEND:'.$dtend.'
LOCATION:'.$meeting_location.'
TRANSP:OPAQUE
SEQUENCE:0
UID:'.$cal_uid.'
DTSTAMP:'.$todaystamp.'
DESCRIPTION:'.$meeting_description.'
SUMMARY:'.$subject.'
PRIORITY:5
X-MICROSOFT-CDO-IMPORTANCE:1
CLASS:PUBLIC
BEGIN:VALARM
TRIGGER:-PT3D
ACTION:DISPLAY
DESCRIPTION:Reminder
END:VALARM
BEGIN:VTIMEZONE
TZID:US/Central
END:VTIMEZONE
END:VEVENT
END:VCALENDAR';   


	$message .= 'Content-Type: text/calendar;name="meeting.ics";method=REQUEST\n';
	$message .= "Content-Transfer-Encoding: 8bit\n\n";
	$message .= $ical;            
 
	//SEND MAIL
	ob_start();

	wp_mail( $email, $subject, $message, $headers, $attachments );

	ob_end_clean();
  
 
}