Page 1 of 1

how to remove attachment

Posted: Sun Mar 23, 2008 2:14 am
by ksmj
I have a program to run through a database data which has email address and a filename for the email address.

The task is to attach the file as specified in the filename to the email address.

I am having problem with my program where by it attached 1 file for the first email, 2 files for the 2nd and 3 files for the 3rd. Obviously, the problem comes from the fact that files kept on being added to the message but the old file for previous email wasn't removed.

So my question is, how do i remove the other files that I attached earlier for other emails.
I have a loop to run through all email address


prepare message
loop while still have email address to send
attach file for this email
send out email
end

what i need is to remove the attachment after i sent out the email, but how do i achieve that?



Thanks in advance



Kelvin

Re: how to remove attachment

Posted: Sun Mar 23, 2008 3:22 am
by Chris Corbyn

Code: Select all

$id = $message->attach($attachment);
$message->detach($id);
EDIT | Changed code, I got mixed up and showed some v4 code

Re: how to remove attachment

Posted: Sun Mar 23, 2008 4:00 am
by ksmj
thanks mate, some how i missed that function when I search through the doc.