Posting a sales invoice with an existing invoice no. went wrong

Posting a sales invoice with an existing invoice no. went wrong. When creating a sales invoice with an existing invoice no., the system automatically adjusts the invoice no. to a new one. However, during the email creation, the existing invoice was incorrectly linked to the email.