Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Page Breaks in Outlook VBA

Status
Not open for further replies.

JimLes

IS-IT--Management
Feb 27, 2006
119
0
0
US
I have the following code that creates the body of an outlook mail message. I want to be able to insert a page break for printing. I have searched but cannot find the HTML code that works. Any ideas?

'Create email message and attach data from recordset
Set oLook = CreateObject("Outlook.Application")
Set oMail = oLook.CreateItem(0)

Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)

'Create body using HTML tags and recordset

'create table, image, and hyperlink

'bodytext = bodytext & "<img src='C:\temp\GPS Logo.jpg' />" & "<br>" 'adds image from location on pc

bodytext = bodytext & "<img src='\\Test\test\GPS Logo.jpg' />" & "<br>"

bodytext = bodytext & "<a href='#English'>English</a>" & "<br>" ' creates link to bookmark in email message


bodytext = bodytext & "<b>" & "Responses for " & rs![_Name] & "</b>" & "<br>" & "</table>" & "<br>"


bodytext = bodytext & "The following answers range from a scale of 1 (Strongly Disagree) to 5 (Strongly Agree)" & "<br>"
bodytext = bodytext & "Question 2: The way my manager provides feedback makes me want to receive feedback more frequently: " & rs![Open_To_MoreFeedback1-5] & "<br>"
bodytext = bodytext & "Question 3: The way my manager provides feedback helps to increase my level of performance: " & rs![Increase_Level_1-5] & "<br>"
bodytext = bodytext & "Question 4: The way my manager provides feedback inspires me to apply what I have learned from my successes and failures: " & rs![Apply_1-5] & "<br>"
bodytext = bodytext & rs![Comment03] & "<br>"
bodytext = bodytext & rs![Comment04] & "<br>"
bodytext = bodytext & rs![Comment05] & "<br>" & "<br>"


bodytext = bodytext & "<a name='English'>English</a>" & "<br>" 'creates bookmark in email message
 
There is no such thing as a 'page break' in HTML. Web pages (in theory) can be infinitely long.

Also printing breaks can be relative to the paper size being used.

However, there is a page break for printing utilising CSS :
Code:
@media print {
    footer {page-break-after: always;}
 }
Taken from
Though you will need to trial and error this to see if HTML emails will honour this CSS as not all CSS is usable in HTML emails.

Perhaps you could use a Word mail merge to produce the document paginated as you desire and use the mailitem wrapper to send the Word doc as an email, though this can be flaky at the best of times, where you are never sure of getting a WYSIWYG email produced from the Word doc!


"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top