Fetching the subject for the messages-to-be-attached went wrong. $i and $start_message have no relation to the indices of the $msg array. Fix this by looping the $msgs array until we find the message with the right id and take that subject. Closes #772371.