none
Send Excel file data with formatting as email body RRS feed

  • Question

  • I want to send excel data with formatting in an email body. I want to use C# as the language and will use Epplus library to read excel data.

    Can anyone please help ?

    Tuesday, June 4, 2019 12:47 PM

All replies

  • Hello,

    You can use the following method to create HTML table from a Excel WorkSheet. Take the resulting string and embed it into your email body.

    If you need assistance using SMTP email see the following page http://www.systemnetmail.com/faq/3.1.2.aspx

    For more advance SMTP coding see my TechNet article

    https://social.technet.microsoft.com/wiki/contents/articles/51936.c-working-with-smtp-email-part-2.aspx


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    Tuesday, June 4, 2019 10:05 PM
    Moderator
  • Thanks Karen, this is helpful.

    But i also want to retain the formatting and style of the Excel file data. Can you help me with that too ?

    Wednesday, June 5, 2019 6:15 AM
  • Hi 

    Thanks for the feedback.

    Based on my search, the following link may be helpful for you to send the formatting of the excel file data.

    https://docs.aspose.com/display/emailnet/Using+a+Microsoft+Excel+Worksheet+as+the+Message+Body+and+Sending+Email

    Note:This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, June 5, 2019 9:22 AM
    Moderator
  • Thanks Karen, this is helpful.

    But i also want to retain the formatting and style of the Excel file data. Can you help me with that too ?

    Hello,

    To be honest I've never used EPPlus but can tell you from a great deal of working with Excel that you need to drill down into each cell that will be written to and integrate the cell's style property, once specifics are known e.g. say a cell is bold you would need to wrap the cell in a <strong> tag, and if the cell has a color you would need to convert the Excel color to HTML color etc. With that (and there are more formatting considerations) the first link I provided would not work. 

    There is an experimental NuGet package that extends EPPlus that might work.

    https://github.com/fitogram/EPPlus.Html


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, June 5, 2019 10:13 AM
    Moderator
  • Hi

    Is your problem solved? If so, please post "Mark as answer" to the appropriate answer, so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,
    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, June 18, 2019 7:21 AM
    Moderator