i am listing the requirement again
1. send mail with some matter in body with to and cc mail id and attached both files
2. will flag in invdata table if error while send the mail
3. will have a scheduled task which will be call this web api of mail
4. web api mail should have two part.
a) send mail for invoice no and attached both files
b) loop for invdata with flag mail not send
and call (a) part to send mail for invoice no and attached both files
is the logic clear
why you need scheduler?
if mail is not send due to error in smpt or anything we want the transaction should get
saved and flag to be set mail not send in invdata table
this schedular will call a script which will call web api part (b)