2

In my website, I need to send a data table to the client via email. I want the table in a good format. I've heard that inline style doesn't work on Outlook so I think about CSS.

I have no idea about how to do this. Using Append method in the StringBuilder class is my only choice. Could you tell me a better way to achieve what I want? Thank you so much.

6
  • 2
    You heard incorrectly. CSS doesn't work on Gmail; you need to use inline styles. Commented May 7, 2013 at 14:27
  • Really? :( Yah, so do you have a better way to write email content, besides using StringBuilder? Commented May 7, 2013 at 14:29
  • You may have a couple of options, but I'm not sure what you mean by StringBuilder being your only choice. How are you sending the email? Are you using the MailMessage object? If you control the outgoing mail message you may be able to add a CSS "file" as a LinkedResource to that message and reference it accordingly. Inline styles may be easier, though. Commented May 7, 2013 at 14:29
  • I mean how write email content effectively. I don't want to concatenate string. Commented May 7, 2013 at 14:31
  • @Forte_201092: That's a completely different question than the one you asked. What's wrong with concatenating strings to build other strings? Is there a particular reason you don't want to do it? An option there could be to store a template somewhere which can be used in a plain old string.Format() and then just populate the template with values. Commented May 7, 2013 at 14:33

1 Answer 1

3

You could use MvcMailer for this purpose. It helps composing Email body using regular ASP.NET MVC views

Sign up to request clarification or add additional context in comments.

5 Comments

Is that a third-party library? Thanks, I'll take a look :)
Yes, it is. It's very convenient way to create email bodies
It works! That's great. But I still have one more question. With MvcMailer, I can send a hard-code page. I want to display the mail, then the admin can write some extra thing, click "Send", and everything goes. Do you know how to do that?
@Forte_201092: Pass a model to your Razor email template.
I don't understand the work of MvcMailer. How can it know which view to send, if we just specify the view's name? If I want to send the Index view in the Home controller, what should I do?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.