How to add multiple attachments to email

(2 posts) (1 voice)

Tags:

No tags yet.

  1. maron, Member

    Hello.

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

    
    DECLARE curs CURSOR FOR
    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('https://mydbrinstalldomain.com/mydbr/report.php?r=7&u1=',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 'myemail@mydomain.com', '', '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.

    Posted 1 year ago #
  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

    Posted 1 year ago #

Reply

You must log in to post.