HTML emails with attachments



Hi all



Last week I spent hours trying to get a form script to work as it wouldn't
format correctly, I thought I had working OK. It's a standard form that gets
submitted, this data gets turned into HTML content and a file attachment, it's
works fine for me using Outlook 2003, but the person this script is for that
also uses outlook 2003 is getting it as an unformatted email see below,
below this I have put my code, have ai missed something?



Thanks



Brian







MIME-Version: 1.0

Content-Type: multipart/mixed;

boundary="==Multipart_Boundary_x94eb31179c733bb742320316394b7b58x"

Cc: Freb Bloggs <fred@xxxxxxxxxx>



Message-Id: <20080527130315.155565F395B@xxxxxxxxxxxxx>

Date: Tue, 27 May 2008 14:03:13 +0100 (BST)

Return-Path: John@xxxxxxxxxx

X-OriginalArrivalTime: 27 May 2008 13:03:15.0115 (UTC)
FILETIME=[067577B0:01C8BFFA]



If you can see this MIME than your client doesn't accept MIME types!



--==Multipart_Boundary_x94eb31179c733bb742320316394b7b58x



Content-Type: text/html; charset="iso-8859-1"



Content-Transfer-Encoding: 7bit



HTML CODE IS HERE



--==Multipart_Boundary_x94eb31179c733bb742320316394b7b58x



Content-Type: application/msword; name="Test CV.doc"

Content-Transfer-Encoding: base64

Content-disposition: attachment; file="Test CV.doc"



FILE BINARY CODE STARTS HERE



UEsDBBQABgAIAAAAIQDwH5iqfQEAAFQFAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIo
oAAC ...



--==Multipart_Boundary_x94eb31179c733bb742320316394b7b58x--





$to = ucwords("$to_name <$to_email>\r\n");

$from = $from_name."<".stripslashes($_POST['email']).">";



$mime_boundary = "==Multipart_Boundary_x".md5(mt_rand())."x";

$bound = "--".$mime_boundary."\r\n";

$bound_last = "--".$mime_boundary."--\r\n";



if ($attachment_found == true) {



$headers .= "From: $from\r\n".

"MIME-Version: 1.0\r\n".

"Content-Type: multipart/mixed;\r\n".

" boundary=\"{$mime_boundary}\"\r\n";

if (!empty($cc_email)) {$headers .= ucwords("cc:
$cc_name <$cc_email>\r\n ");}



$message .= "If you can see this MIME than your client
doesn't accept MIME types!\r\n"

.$bound;



$message .= "Content-Type: text/html;
charset=\"iso-8859-1\"\r\n"

."Content-Transfer-Encoding: 7bit\r\n\r\n"

."$email_body\r\n"

.$bound;



$message .= "Content-Type: $f_type; name=\"$f_name\"\r\n"

."Content-Transfer-Encoding: base64\r\n"

."Content-disposition: attachment; file=\"$f_name\"\r\n"

."\r\n"

.$f_data;

$message .=$bound_last;

} else {

$headers = "MIME-Version: 1.0\n";

$headers .= "Content-type: text/html; charset=iso-8859-1\n";

$headers .= "From: $from_name <".$_POST['email'].">\r\n";

$to = ucwords("$to_name <$to_email>\r\n");

if (!empty($cc_email)) {

$headers .= ucwords("cc: $cc_name <$cc_email>\n");

}

$message = $email_body;

}

$subject = $form_subject;

if (@mail($to, $subject, $message, $headers)) {

header("Location: $responcepage");

} else {

echo "Failed to send email";

}






.



Relevant Pages

  • Re: ?MAPI forms for Outlook Designer
    ... Sue Mosher, Outlook MVP ... > Customer may design my forms, like Outlook standart forms by Outlook Form ... > He also can extends my form logic by form script. ...
    (microsoft.public.outlook.program_forms)
  • Re: ?MAPI forms for Outlook Designer
    ... like Outlook standart forms by Outlook Form ... He also can extends my form logic by form script. ... How can i do my MAPI custom form like Outlook defaults (editable by Form ... How can i create my own custom form like standard Outlook form? ...
    (microsoft.public.outlook.program_forms)