one of the documented procedures in this installation of the ACS
ec_email_new_gift_certificate_order   gift_certificate_id
What it does:
Use this to send out the "New Gift Certificate Order" email after a gift certificate order is authorized.
Defined in: /web/philip/tcl/ecommerce-email.tcl

Source code:

    set db [ns_db gethandle subquery]
    set selection [ns_db 1row $db "select g.purchased_by as user_id,, g.recipient_email, g.amount
    from ec_gift_certificates g, users u
    where g.purchased_by=u.user_id
    and g.gift_certificate_id=$gift_certificate_id"]
    set system_name [ad_system_name]
    set customer_service_signature [ec_customer_service_signature]

    # have to get rid of ampersands in above variables because they 
    # mess up regsubs
    regsub -all "&" $recipient_email {\\&} recipient_email
    regsub -all "&" $system_name {\\&} system_name
    regsub -all "&" $customer_service_signature {\\&} customer_service_signature
    # Note: template #4 is defined to be the "New Gift Certificate Order" email
    set selection [ns_db 1row $db "select subject as email_subject, message as email_body, issue_type_list from ec_email_templates where email_template_id=4"]

    # and get rid of ctrl-M's in the body
    regsub -all "\r" $email_body "" email_body

    regsub -all "system_name_here" $email_body $system_name email_body
    regsub -all "recipient_email_here" $email_body $recipient_email email_body
    regsub -all "certificate_amount_here" $email_body [ec_pretty_price $amount] email_body
    regsub -all "customer_service_signature_here" $email_body $customer_service_signature email_body

    ns_db dml $db "begin transaction"

    # create a customer service issue/interaction/action
    set user_identification_and_issue_id [ec_customer_service_simple_issue $db "" "automatic" "email" "[DoubleApos "To: $email\nFrom: [ad_parameter CustomerServiceEmailAddress ecommerce]\nSubject: $email_subject"]" "" $issue_type_list $email_body $user_id "" "f" $gift_certificate_id]

    set user_identification_id [lindex $user_identification_and_issue_id 0]
    set issue_id [lindex $user_identification_and_issue_id 1]

    # add a row to the automatic email log
    ns_db dml $db "insert into ec_automatic_email_log
    (user_identification_id, email_template_id, gift_certificate_id, date_sent)
    ($user_identification_id, 4, $gift_certificate_id, sysdate)

    ns_db dml $db "end transaction"

    set email_from [ec_customer_service_email_address $user_identification_id $issue_id]
    ec_sendmail_from_service "$email" "$email_from" "$email_subject" "$email_body"

    ns_db releasehandle $db