Referring to following documents about your use case on how to get the PDF:
Creating PDF In ASP.NET Core MVC Using Rotativa.AspNetCore[
^]
How to create PDF from Asp.net MVC with RotativaHQ[
^]
Once that is in place, code snippet like below should do the job:
var attachment = new Attachment(new MemoryStream(pdfBytes), PdfFileName);
MailMessage mailMessage = new MailMessage();
mailMessage.To.Add(new MailAddress("to@to.t"));
mailMessage.From = new MailAddress("from@from.f");
mailMessage.Subject = "my pdf attached";
mailMessage.Attachments.Add(attachment);
SmtpClient smtp = new SmtpClient();
smtp.Connect("smtp.gmail.com",465, true);
smtp.Authenticate("emailAddress", "Pwd");
smtp.Send(mailMessage);
PS: Make sure to take care of memory release for the objects.
UPDATE: A better way to wireup your email configurations/sending email:
How to Send an Email with Attachments in ASP.NET Core - Code Maze[
^]
Try out!