[dbo].[EmailApiMarkSuccess]
CREATE PROCEDURE [dbo].[EmailApiMarkSuccess]
@inOutgoingEmailQueueIds IntList readonly,
@inSentAt datetimeoffset,
@inCompletedAt datetimeoffset,
@inRequestTraceId varchar(64)
AS
begin
set nocount on
insert into OutgoingEmailSuccess
(
OutgoingEmailFID,
EnqueuedAt,
SentAt,
CompletedAt,
RequestTraceId
)
select
OutgoingEmail.OutgoingEmailID,
OutgoingEmailQueue.EnqueuedAt,
@inSentAt,
@inCompletedAt,
@inRequestTraceId
from @inOutgoingEmailQueueIds EmailQueueIds
inner join OutgoingEmailQueue on EmailQueueIds.Item = OutgoingEmailQueue.OutgoingEmailQueueID
inner join OutgoingEmail on OutgoingEmailQueue.OutgoingEmailFID = OutgoingEmail.OutgoingEmailID
order by EmailQueueIds.Item asc
exec SyncOutgoingEmailStatus
@inOutgoingEmailQueueIds = @inOutgoingEmailQueueIds,
@inActivityTimeStamp = @inCompletedAt,
@inSucceeded = 1
delete OutgoingEmailQueue
from @inOutgoingEmailQueueIds EmailQueueIds
inner join OutgoingEmailQueue on EmailQueueIds.Item = OutgoingEmailQueue.OutgoingEmailQueueID
end
GO
GRANT EXECUTE ON [dbo].[EmailApiMarkSuccess] TO [MssExec]
GO