Question

I am creating an email using the c# MailMessage and I am trying to add a checkbox that doesn't need to be clicked. The checkboxes will be used for a checklist of what to bring to an event (like a packing list). I have:

MailMessage objEmail = new MailMessage();
objEmail.From = new MailAddress("sender@hotmail.com");
objEmail.To.Add(new MailAddress("example1@hotmail.com"));
objEmail.CC.Add(new MailAddress("example2@hotmail.com"));
objEmail.Bcc.Add(new MailAddress("example3@hotmail.com"));

objEmail.Subject = "Packing list!";
objEmail.IsBodyHtml = true;

objEmail.Body = @"<div width=""800px"">
    <h3>WHAT TO BRING</h3>
    <form>
        <input type=""checkbox"" name=""item"" value=""shirt"">Shirt<br>
        <input type=""checkbox"" name=""item"" value=""shoes"">Shoes 
    </form></div>";

but when I send the email the checkboxes do not appear in the list.

Output in outlook using outlook.com:

WHAT TO BRING

I have a bike
I have a car


Output in outlook using Microsoft Outlook:

WHAT TO BRING

[ ]I have a bike
[ ]I have a car


Output in outlook using hotmail.com:

WHAT TO BRING

I have a bike
[]I have a car

So the problem is with the mail client but it is inconsistent what the problem is. I s there any way to make a consistent output? Is there a way with html that works to create the checkboxes or do I just need to include images of a checkbox? Thanks in advance.

Was it helpful?

Solution

My guess is that their in inconsistency with the way the email clients handle check boxes.

Why not change each to [X] which is plain text so all email clients can see it.

OTHER TIPS

Outlook.com has an issue to display multiple check or radio buttons within a single parent. / / / etc add a table in there and add the 2 check boxes in a separate row and it should work fine.

weird Microsoft thinking

All email clients have their own rules on what's allowed. You may find that most providers don't allow JavaScript and just some allow positioning elements while some don't.

Your best bet is to use a plain text form or maybe an image of what the form looks like. And when I say image, don't mean make the entire thing an image, have images for each checkbox. Once you click anywhere in this form it opens up on your site to interact with it.

Furthermore, you really shouldn't be building html in your code like you are. Put that in an MVC view or a webforms partial and invoke the file from code. Using this approach you can still inject dynamic data into the template while putting the HTML where it belongs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top