Yogesh Ghorpade

Yogesh Ghorpade

  • NA
  • 762
  • 148.2k

how to Generate QR code dynamically and send to mail ??

Sep 10 2018 1:21 AM
Hello
 
how to Generate QR code dynamically and Send to mail Using C# Window Application
 
QRCodeGenerator qrGenerator = new QRCodeGenerator();
QRCodeGenerator.QRCode qrCode = qrGenerator.CreateQrCode(dtAccess.Rows[rows]["InvitationId"].ToString() + "_" + dtAccess.Rows[rows]["First_Name"].ToString() + "_" + dtAccess.Rows[rows]["Last_Name"].ToString() + "_" + dtAccess.Rows[rows]["Mobile"].ToString() + "_" + dtAccess.Rows[rows]["Email_1"].ToString(), QRCodeGenerator.ECCLevel.Q);
Bitmap qrCodeImage = qrCode.GetGraphic(20);
System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();
imgBarCode.Height = 120;
imgBarCode.Width = 120;
using (Bitmap bitMap = qrCode.GetGraphic(20))
{
using (MemoryStream ms = new MemoryStream())
{
bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
byte[] byteImage = ms.ToArray();
imgBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
}
string imageContent = "<img src='" + imgBarCode.ImageUrl + "' alt='Alternate Text' />";
string body = "Hello {0},<br /><br />QR Code For Event Name, At Address,Date,Time <br /><br />" + imageContent + "<br/><br />" + dtAccess.Rows[rows]["InvitationId"].ToString() + "<br/><br/>Thanks.";
MultipleRecipeintEmail(dtAccess.Rows[rows]["Email_1"].ToString(), "Invitation", body, imgBarCode.ImageUrl);
}
}
 
I am using this code mail send but image not display. Please Help!!

Answers (5)