Search code examples
c#winformsdevexpressoutlook-api

change GridView table style when sending to outlook


I have this code that send GridView data to outlook

 Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
            Microsoft.Office.Interop.Outlook.MailItem oMsg = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

            string str;
            MemoryStream ms = new MemoryStream();
            try
            {
                gridView2.OptionsPrint.AutoWidth = false;
                gridView2.OptionsPrint.UsePrintStyles = true;
                gridView2.ExportToHtml(ms);
                ms.Seek(0, SeekOrigin.Begin);
                StreamReader sr = new StreamReader(ms);
                str = sr.ReadToEnd();
            }
            finally
            {
                ms.Close();
            }

            oMsg.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
            oMsg.Display(false); 
            oMsg.HTMLBody = OrderNumber + str +oMsg.HTMLBody;

the table look like this enter image description here

but i want table style to be like this enter image description here

how can i do that,Thanks in advance


Solution

  • Set the GridView.AppearancePrint.HeaderPanel.BackColor property to White to change a column header background color.

    Refer to the Appearance and Conditional Formatting help article that describes different ways of appearance customizations.