How to add multiple attachments to email

(2 posts) (1 voice)


No tags yet.

  1. maron, Member


    I have a procedure which is intended to group various invoices together and send them out.

    select i.e_id, i.merc_id, o.o_id .... DECLARE CONTINUE HANDLER FOR NOT FOUND SET bDone = 1; OPEN curs; SET bDone = 0;
    emailLoop: LOOP
    FETCH curs INTO invoice_id, merchant_increment_id, order_id;
    IF bDone THEN
    CLOSE curs;
    LEAVE emailLoop;
    END IF; IF( invoice_id is not null ) THEN
    SET vURL = concat('',invoice_id,'&m=1&h=xxxx&export=pdf'); select invoice_id, merchant_increment_id, order_id;
    select 'dbr.mail.attach',concat(merchant_increment_id,'.pdf'),vURL; END IF; END LOOP; select 'dbr.mail',1;
    select 'dbr.mail.sender',....
    select 'dbr.mail.smtp.user',....
    select 'dbr.mail.smtp.server',....
    select 'dbr.mail.debug',1;
    select '', '', 'Invoices', 'Email body .';

    I have tested all code back and forward, I should be attaching 5 records but am only getting the latest one as an attachment. I have removed all email statements and just output the select. Am I doing something incorrect in adding multiple attachments.

  2. maron, Member

    Sorry - this was my error.

    The extra select statement after setting the vURL variable triggers the execution of the command above. Therefore only the last one works.

    Fixed now and works - please disregard


You must log in to post.