I am generating QR code in c# using the qrcoder library. I can generate the code with the information i want, but i would like to send it also through email.
Using following code i get the email, but it won't display the image of the QR code in it. And if I change the address in which I think the code its being saved it also give an error like this:
System.Runtime.InteropServices.ExternalException occurred A generic error occurred in GDI+.
Here is the code:
public void GenerateQR(string infoReserva)
        {
            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData qrCodeData = qrGenerator.CreateQrCode(infoReserva, QRCodeGenerator.ECCLevel.Q);
            QRCode qrCode = new QRCode(qrCodeData);
            
            using (Bitmap bitMap = qrCode.GetGraphic(20))
            {
                bitMap.Save(Server.MapPath("~/Images/qrcode.png"), ImageFormat.Png);
            }
          
            MailMessage mm = new MailMessage();
            mm.From = new MailAddress("name@exampple.comr");
            mm.Subject = "How to email self-generated QR code";
            mm.Body = " <html><body> <p> QR code as below</p> <p> <img src='http://localhost:44362//Images/qrcode.png' alt='QR Code'/></p> </body></html> ";
            mm.To.Add("name@exampple.com");
            mm.IsBodyHtml = true;
            SmtpClient smtp = new SmtpClient();
            smtp.Host = "smtp.gmail.com";
            smtp.EnableSsl = true;
            NetworkCredential NetworkCred = new NetworkCredential();
            NetworkCred.UserName = "name@exampple.comr";
            NetworkCred.Password = "-----";
            smtp.UseDefaultCredentials = true;
            smtp.Credentials = NetworkCred;
            smtp.Port = 587;
            smtp.Send(mm);
        }
I have the code of my project organized in folder like this:
- 1_Entites
- 2_DataAcces
- 3_Exceptions
- 4_API
- 5_WEBAPP
The first 4 folder are the backend of the aplications, and the folder named WebApp is in which i have this code and the front end of the app, in this folder i created the folder of Images Do you know what is the best way of sending this email with de qr code
Thanks in advance!
 
     
    