Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Php- worddokument als mailanhang

Empfohlene Antworten

Veröffentlicht

Hi,

wie kann oder womit kann ich ein Worddokument an eine Email anfügen.

Ich habe zuerst ein Rtfdokument, welches ich mit Daten aus einer Datenbank fülle und als Worddokument abspeicher. Nun möchte ich das neue Worddokument als Anhang an eine Email anfügen. Wie zum ....... kann ich das umsetzen.


function _send_Antrag($antrag_id)
{

$text = "../../dokument.doc";
//dieses Dokument soll im Anhang der Email versendet werden

$file = fopen($text,"r");
$text = fread($file,filesize($text));
fclose ($file);

$text_start = "Antrags-ID: " . $antrag_id . "\n\n";

$text = $text_start . $text;

$mail_object = &Mail::factory('sendmail');

$headers['From'] = $GLOBALS["OPEN_SOURCE_ABSENDER"];
$email = "meineadresse@kdvz.de";
$headers['To'] = $email;
$headers['Subject'] = 'Antrag_ID:' .$antrag_id. " " . date("d.m.y H:i:s");

$email = $mail_object->send($email, $headers, $text);

//bisheriger Gedanke ist Dokument als $text anfügen. Das geht aber nicht,
weil dies der Text in der Email ist. Ich brauche das Dok aber als Anhang

if(PEAR::isError($email)){
$error = "( " . $email->getMessage() . " ) !";
}

return $error; } [/PHP]

Jetzt habe ich es so, trotzdem stürtz er ab und macht nichts :(


function _sendtest(){


//$text = 'This is a text message.'; // Text version of the email
$html = '<html><body><p>This is a html message</p></body></html>'; // HTML version of the email

$crlf = "\n";
$headers['From'] = $GLOBALS["OPEN_SOURCE_ABSENDER"];
$email = "adresse@x.de";
$headers['To'] = $email;
$headers['Subject'] = 'Antrag_ID:' .$antrag_id. " " . date("d.m.y H:i:s");

// Creating the Mime message
$mime = new Mail_mime($crlf);

// Setting the body of the email
//$mime->setTXTBody($text);
$mime->setHTMLBody($html);

// Add an attachment
$file = "x.doc"; // Content of the file
$file_name = "x.doc"; // Name of the Attachment
$content_type = "Application/doc"; // Content type of the file
$mime->addAttachment ($file, $content_type, $file_name, 1); // Add the attachment to the email
$body = $mime->get();
$headers = $mime->headers($headers);

// Sending the email
$mail =& Mail::factory('sendmail');
$mail->send($recipient, $headers, $body);
}[/PHP]

Bekomme weiterhin keinen Anhang.. die Email wird aber versendet! Jemand ne Idee?

$text                  = " Antrags-ID: "  . $antrag_id . "\n\n"; 
// $crlf = "\n";

$mail_object = &Mail::factory('sendmail');

$headers['From'] = $GLOBALS["OPEN_SOURCE_ABSENDER"];
$email = "mail@test.de";
$headers['To'] = $email;
$headers['Subject'] = ' Antrag_ID:' .$antrag_id. " " . date("d.m.y H:i:s");

// $mime = new Mail_mime($crlf);
$mime = new Mail_mime();
$file = file_get_contents(dirname(__FILE__) . "/x.doc");
//$file="x.doc";
$file_name = "x.doc";
$content_type = "Application/msword";
$mime->addAttachment ($file, $content_type, $file_name,1);
$body = $mime->get();

$email = $mail_object->send($email, $headers, $text,$body);



if(PEAR::isError($email))
{
$error = "( " . $email->getMessage() . " ) !";
}


return $error;[/PHP]

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.