Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7434797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:57:06+00:00 2026-05-29T09:57:06+00:00

I have a project requirement that we need to attach an HTML formatted log

  • 0

I have a project requirement that we need to attach an HTML formatted log sheet to an email that gets sent to a user. I don’t want the log sheet to be part of the body. I’d rather not use HTMLTextWriter or StringBuilder because the log sheet is quite complex.

Is there another method that I’m not mentioning or a tool that would make this easier?

Note: I’ve worked with the MailDefinition class and created a template but I haven’t found a way to make this an attachment if that’s even possible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:57:06+00:00Added an answer on May 29, 2026 at 9:57 am

    Since you’re using WebForms, I would recommend rendering your log sheet in a Control as a string, and then attaching that to a MailMessage.

    The rendering part would look a bit like this:

    public static string GetRenderedHtml(this Control control)
    {
        StringBuilder sbHtml = new StringBuilder();
        using (StringWriter stringWriter = new StringWriter(sbHtml))
        using (HtmlTextWriter textWriter = new HtmlTextWriter(stringWriter))
        {
            control.RenderControl(textWriter);
        }
        return sbHtml.ToString();
    }
    

    If you have editable controls (TextBox, DropDownList, etc), you’ll need to replace them with Labels or Literals before calling GetRenderedHtml(). See this blog post for a complete example.

    Here’s the MSDN example for attachments:

    // Specify the file to be attached and sent.
    // This example assumes that a file named Data.xls exists in the
    // current working directory.
    string file = "data.xls";
    // Create a message and set up the recipients.
    MailMessage message = new MailMessage(
       "jane@contoso.com",
       "ben@contoso.com",
       "Quarterly data report.",
       "See the attached spreadsheet.");
    
    // Create  the file attachment for this e-mail message.
    Attachment data = new Attachment(file, MediaTypeNames.Application.Octet);
    // Add time stamp information for the file.
    ContentDisposition disposition = data.ContentDisposition;
    disposition.CreationDate = System.IO.File.GetCreationTime(file);
    disposition.ModificationDate = System.IO.File.GetLastWriteTime(file);
    disposition.ReadDate = System.IO.File.GetLastAccessTime(file);
    // Add the file attachment to this e-mail message.
    message.Attachments.Add(data);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In our project we have requirement that, after receiving sms message from third party
In our project we have a requirement that when a set of records are
I have a project where the requirements is that a end user will select
I have a project requirement where I need to authenticate against ActiveDirectory in a
Hey all, I have something of an interesting requirement for my project. I need
I have a project requirement to render HTML and capture the rendered image as
I have a requirement in my .NET project where I need to select an
Requirement of my project is, if device have internet connectivity, need to get the
So I have a project that uses the old-style encodeObject:/decodeObject NSCoder serialization. I need
For a project I need to move Tokens between nodes that have no transitions

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.