Continia Document Output does similar. If you want to progress it in house without product dependency the report selections table does have some good integration events to try out:
this one for instance could be useful as you can check the report usage is the invoice and with the DocNo reference to check the sales invoice record has a sales order ref. If it does you can use that as a filter on the shipment table.
[IntegrationEvent(false, false)]
local procedure OnBeforeSendEmailToCust(ReportUsage: Integer; RecordVariant: Variant; DocNo: Code[20]; DocName: Text[150]; ShowDialog: Boolean; CustNo: Code[20]; var Handled: Boolean)
begin
end;