Hi,
I was trying to capture div contents and send to email but when I tested it, I got this Ststem.Byte[]
Here is what I got
I then tried this, but may I please know the correct one to use, please? I have image controls to the AlternateView
protected void SendToMail_Click1(object sender, EventArgs e)
{
using (MailMessage mm = new MailMessage("******@email.com", maillbl.Text))
{
mm.Subject = "Event";
mm.AlternateViews.Add(Mail_Body1());
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient
{
Host = "relay-hosting.secureserver.net",
EnableSsl = false
};
NetworkCredential NetworkCred = new NetworkCredential("******@email.com", "****************");
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 25;
smtp.Send(mm);
}
}
private AlternateView Mail_Body1()
{
string platform = "Signed by management";
string user = username.Text;
string base64 = Request.Form[HiddenField1.UniqueID].Split(',')[1];
byte[] bytes = Convert.FromBase64String(base64);
string body = "<p Style='font-size: 14px;'>Hello " + user + ",</p>";
body += "<img src=\"cid:" + bytes + "\">"; //This is the first Image control I added
body += "<img src=cid:" + bytes + "id='img' alt='' width='100px' height='100px'/>"; //This is another Image control I added
body += "<p Style='height: 300px; width: 300px;'>" + bytes + "</p>"; //This is what I used initially to test, which gave me tha error
body += "<p Style='font-size: 14px;'>Best Regards,</p>";
body += "<p Style='font-size: 14px;'>" + platform + "</p>";
ContentType mimeType = new System.Net.Mime.ContentType("text/html");
AlternateView alternate = AlternateView.CreateAlternateViewFromString(body, mimeType);
return alternate;
}