Help with ics attachment in Email

Hi there,

Hopefully one of you great people can help as I’m completely lost with it. I cannot manage to get an email attachment to sent after so many days of trying. I’m sure the headers are wrong, but just not sure what they should be, can you help?
[php]
if (!is_array($_POST))
return;
reset($_POST);

while(list($key, $val) = each($_POST)) {
$GLOBALS[$key] = stripslashes($val);
$val=stripslashes($val);
}

// Is there an email address? Should be…
$MailFormEmail_new = $MailFormEmail;
if (!$MailFormEmail_new) {
$MailFormEmail_new = "[email protected]";
}

// Compile the message to us
$Message .=
"
Company:
$MailFormCompany\n
Sender:
$MailFormName\n
Contact number:
$MailFormNumber\n
Email:
$MailFormEmail_new\n
Query:
$MailFormQuery\n
Query orignated:
IP: $MailFormIP
HTTP Origin: $MailFormHTTPref
HTTP Agent: $MailFormHTTPagent
";

// Who’s it going to and what Subject?
$MailFormToAddress = "[email protected]";
$MailFormSubject = “Online Enquiry from “.$MailFormName.” (”.$MailFormCompany.")";

// Header and footer of email
$Header = "Hi there \nYou have received an online enquiry from “.$MailFormName.” of “.$MailFormCompany.”\n\nThe Message was sent at “.date(“H:i”).” on ".date(“l dS \of F Y O”);

$Footer = “Please have a look and contact them as soon as possible.\n\nKind Regards\nYour Website\n”;

if ($Header) {
$Message = $Header."\n\n".$Message;
}

if ($Footer) {
$Message .= "\n\n".$Footer;
}

$uid = "[email protected]";
$datestampnow = date(“Ymd”) . “T” . date(“Hms”).“Z”;
$startdate = “20110201T100000Z”;
$enddate = “20110201T103000Z”;
$desc = “Description box”;
$summary = “Summary box”;
// Now create calendar file

$myFile = “dispatch.ics”;

$fh = fopen("$myFile", “x+”);

$icscard = sprintf(“BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Google Inc//Google Calendar 70.9054//EN\nMETHOD:PUBLISH\nVERSION:2.0\n
CALSCALE:GREGORIAN\nBEGIN:VEVENT\nDTSTART:%s\nDTEND:%s\nDTSTAMP:%s\nCREATED:%sUID:%s\nDESCRIPTION:%s\nLAST-MODIFIED:%s\nLOCATION:\nSEQUENCE:0\nSUMMARY:%s\nTRANSP:OPAQUE\nEND:VEVENT\nEND:VCALENDAR\n”,
$startdate,
$enddate,
$datestampnow,
$datestampnow,
$uid,
$desc,
$datestampnow,
$summary);

str_replace("\t", “”, $icscard);

fwrite($fh, $icscard);
fclose($fh);

$Message->Attach[] = array(
‘content’ => $icscard,
‘type’ => ‘text/calendar’,
‘name’ => ‘dispatch.ics’,
‘charset’ => ‘utf-8’,
‘encoding’ => ‘base64’
);

// End creation of calendar file

// Now create email headers
$random_hash = md5(date(‘r’, time()));
$header = “From: $MailFormEmail_new”;
$headers .= “\r\nContent-Type: multipart/mixed; boundary=0003255584f2a0934e04995f9d4a”;

// You have mail!
mail( “$MailFormToAddress”, “$MailFormSubject”, “$Message”, “$headers”);

unlink($myFile);
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service