Changeset 13f1472 for resTools_backend/backend/Email/EmailSender.cs
- Timestamp:
- 09/18/22 18:09:53 (2 years ago)
- Branches:
- master
- Parents:
- 49b0bbd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
resTools_backend/backend/Email/EmailSender.cs
r49b0bbd r13f1472 1 using SendGrid; 1 using backend.Data; 2 using backend.Entities; 3 using SendGrid; 2 4 using SendGrid.Helpers.Mail; 3 5 … … 9 11 public class EmailSender : IEmailSender 10 12 { 13 14 private readonly DataContext _context = null; 15 public EmailSender(DataContext context) 16 { 17 _context = context; 18 } 19 11 20 public async Task SendEmailAsync(string subject, string message, string toEmail) 12 21 { 13 var client = new SendGridClient("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"); 14 var msg = new SendGridMessage()22 23 _context.QueueItems.Add(new QueueItem() 15 24 { 16 From = new EmailAddress("danilo.najkov@students.finki.ukim.mk", "Danilo"),17 25 Subject = subject, 18 PlainTextContent= message,19 HtmlContent = message20 };21 msg.AddTo(new EmailAddress(toEmail));22 msg.SetClickTracking(false, false);23 var response = await client.SendEmailAsync(msg);26 Message = message, 27 Reciptient = toEmail, 28 CreatedAt = DateTime.UtcNow, 29 Retries = 0 30 }); 31 await _context.SaveChangesAsync(); 24 32 } 25 33 }
Note:
See TracChangeset
for help on using the changeset viewer.