1

i am trying to send e mail via outlook by php. i succeed this with this code, but i couldnt find how to add an attachmnet.

$subject="Hi from your city";
$message= "hello my darling";

$to="example@gmail.com";
// starting outlook        
com_load_typelib("outlook.application"); 

if (!defined("olMailItem")) {define("olMailItem",0);}

$outlook_Obj = new COM("outlook.application") or die("Unable to start Outlook");

//just to check you are connected.        
echo "Loaded MS Outlook, version {$outlook_Obj->Version}\n";        
$oMsg = $outlook_Obj->CreateItem(olMailItem);  

$oMsg->Recipients->Add($to);

$oMsg->Subject=$subject;        
$oMsg->Body=$message;        
$oMsg->Save();        
$oMsg->Send();    
Hasan Yilmaz
  • 108
  • 8

1 Answers1

0

i found. this is working with full path.

$oMsg->Attachments->Add("C:\xampp\htdocs\outlook\file.txt");

Hasan Yilmaz
  • 108
  • 8