Reputation: 2046
I'm using PHP with the Outlook Application COM class. Currently I can send from the server and a client just fine so I know it's setup correctly. My issue comes from the need to allow additional attachments to the email before sending it. The emails being sent are for the most part exactly the same, but the attachments could change. The attachments are typically excel files that change depending on the recipient, not that the format matters, only the fact that the files are different per recipient.
This is the code I have so far:
$objApp = new COM("outlook.application") or die("Unable to Load Outlook");
$email = $objApp->CreateItem(0);
$email->To = $receiver;
$mail->From = '[email protected]';
$mail->FromName = $sender;
$email->Subject = $subject;
$email->HTMLBody = $emailbody;
$email->attachments->Add($folder.$file);
$email->Display();
The behavior is that when I click a button this script fires and it opens up a 'New' email window in Outlook 2007 with the information for subject, body, sender, receiver and a template attachment. The sender though needs to be able to add other attachments if necessary. When I run this on the server machine, Outlook opens the 'New' email window without issue. But when I try to create the email from a client computer, the 'New' email window opens on the server rather than the client. That behavior is pointless as the users aren't right next to the server to finish the email and send it. Does anybody know how to get the 'New' email window to open on the client computer?
PS (I understand that I could create a form that allows uploads and then sends an email with those attachments, but I'd rather not re-create the wheel if I don't have to...)
Upvotes: 1
Views: 447
Reputation: 66215
You can use a mailto link on the client side to open the message locally, but mailto: url does not support attachments.
You can also have a client script to create an instance of the Outlook.Application object locally, but it will only work under IE and your site must be trusted to be able to create local COM objects.
Upvotes: 1