private async Task QueueEmailAsync(string recipient, string subject, string body) { if (RecipientOverride != null) { recipient = RecipientOverride; } var email = new Email { To = recipient, Body = body, Subject = subject, FromName = "WPS Attendance" }; var serialized = JsonConvert.SerializeObject(email); var guid = Guid.NewGuid().ToString("D"); var blob = Container.GetBlockBlobReference(guid); await blob.UploadTextAsync(serialized); await Queue.AddAsync(guid); }
private async Task QueueEmailAsync(string recipient, string subject, string body, string attachmentHtml = null) { if (RecipientOverride != null) { recipient = RecipientOverride; } var email = new Email { To = recipient, Body = body, Subject = subject, FromName = "WPS Behaviour", AttachmentHtml = attachmentHtml }; var serialized = JsonConvert.SerializeObject(email); var guid = Guid.NewGuid().ToString("D"); var blob = Container.GetBlockBlobReference(guid); for (var attempt = 1; attempt <= 5; attempt++) { try { await blob.UploadTextAsync(serialized); await Queue.AddAsync(guid); return; } catch when(attempt < 5) { await Task.Delay(2000 *attempt); } } }