Link to home
Create AccountLog in
Avatar of gtwmb
gtwmb

asked on

Insert page break in Outlook HTMLBody

Working on a report for an Outlook plug in which could contain one or more tables (using the HMTLBody property of an Outlook message).  If the report contains more than one table, I want to insert a page break in between the tables.  However, when I do a page preview in Outlook, the tables are all on one page.  Does anyone know how to insert a page break into the HTMLBody of an Outlook message?
// newMail defined above
string body = "<br style='page-break-before:always'>";
body += "<table>";
// table code here
body += "</table>";
newMail.HTMLBody = body;
newMail.Display(false);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of b0lsc0tt
b0lsc0tt
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of gtwmb
gtwmb

ASKER

Thanks - I tried <p class=pageBreak> where the pageBreak class is simply page-break-before:always and that didn't work either.  When I look at the "View Source" in the resulting Outlook message (after sending) - it looks like Outlook is doing a lot of reformatting of the HTML between the creation of the message and sending it.  
Avatar of gtwmb

ASKER

OK - I take that back - it works if it isn't the first table in the message - I guess it assumes you want the first table on the first page (I want them all to be on their own page.  I am going to try and put something before the first table and see if it bounces to the second page.  I will award you the points because changing to the <p> tag sent me on my way - many thanks!
Your welcome!  I'm glad I could help.  I did make the assumption you mentioned, this was to break after the first table.  Hopefully you will be able to find what you need for the stuff before the first table.
Thanks for the grade, the points and the fun question.
bol
Avatar of gtwmb

ASKER

You're welcome.  I just added one empty <p></p> tag set before the <p class=pageBreak></p> tags and now my print preview shows the message header as page 1, then each table on its own page after that.  All is well.