My website allows users to create invoices (and also automatically generate pdf files of the invoice) and send it to their receiver via email. Should I have a feedback dialog with an "ok" button that users have to click to close dialog the or should it automatically disappear a few seconds after the process has finished to let the user know that they have done all they needed to do.
Do not add a dialog with an OK button. Dialogs are intrusive and should only be used when an action is required from your users.
In stead you could go with a confirmation bar. See the example below. it's a screenshot from a project I'm working on. After creating an item the user returns to the list view of all of his items. Above the list there is a bar that confirms to the user that he has successfully completed his action.
This way your users can continue with other tasks (if any) or leave this window all together without any disruptions.
An alternative might be to have the confirmation as a final 'step' in your process. In that case the OK button is a part of the flow.
It is better to show that something is busy and confirm it's done afterwards. This way nothing is hidden and no message will show up unexpectedly. Needless to say this shouldn't block the application. Instead, reserve space for a status indication:
[8:58] Sending 5 invoices...
You can make it clickable or add a small button to show the progress, recipients etc.
When it's done, use the same space to show it is finished:
[9:00] 5 invoices sent
The time helps to identify the age of the message. Add a small (x)-button to close the message but don't hide it automatically after a period because than the message could be missed.