I can't figure out how to add padding/indents on the two list items below in the html body (lines 4 and 5 of .html body). It looks like I need to add some padding via CSS, but I do not know how to do that.
Sub Email_File()
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailAddress As String
Dim xMailAddress2 As String
Dim wb1 As Workbook
Dim attch As String
Dim subj As String
Set wb1 = Workbooks("IOM Denial.xlsm")
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailAddress = Workbooks("IOM Denial.xlsm").Sheets("Home").Range("B7").Value
xMailAddress2 = Workbooks("IOM Denial.xlsm").Sheets("Home").Range("B13").Value
attch = wb1.Sheets("Home").Range("B21").Value
subj = wb1.Sheets("Home").Range("B17")
With xOutMail
.To = xMailAddress
.CC = xMailAddress2
.BCC = ""
.Subject = subj
.HTMLBody = "<p>Operations Leadership,</p>" & _
"<p>An inventory performance summary of your submitted IOM requested products is attached. The IOM Summary tab displays the families that are approved or denied based on whether they met the minimum performance turn threshold.</p>" & _
"Products are evaluated for performance by family" & _
"<li>Approved products will be scheduled the same as before, based on forecast availability and prioritized by tier productivity</li>" & _
"<li>Denied products are due to a minimum turn threshold of productivity that is not met</li>" & _
"<p>Attached is an inventory performance report based on the family of products that are requested in the associated IOM. This includes your turn and tier performance, inventory and sales information, the minimum turn threshold and national rank for your territory and decision of Yes/No for approval.</p>" & _
"<p>In addition - we have included three tabs that provide potential opportunities for redeployment within your territory. Each tab report shows your productivity in each family: by account, by demand model (SISO) and evaluating loose shelf inventory and/or inventory contained in sales team and sales associate locations.</p>" & _
"<p>For those product families where the turn threshold is not met, (NO in column J) please review the performance metrics. Utilizing the 3 tabs, evaluate the productivity of the identified Parked account turns, site demand model kit delta and misc inventory locations that carry this product family and work to reallocate / rebalance the inventory to meet the need of this particular IOM.</p>"
.Attachments.Add attch
.Display '.Send
End With
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
This is basically what I am wanting to do with those two lines, just can't figure out how to specifically write the code within VBA
<html>
<head>
<style>
p.padding {
padding-left: 2cm;}
</style>
</head>
<body>
<h1>The padding-left Property</h1>
<p>This is a text with no left padding.</p>
<p class="padding">This text has a left padding of 2 cm.</p>
</body>
</html>
You can try this, this is called inline css
<li style="padding-left:5px"> your texts </li>
Also padding have left, right, top and bottom options if you are interested in too. I suggest you learn css, if you are to delve in web development.
Edit: I saw your edit now, you can use it like this.
<style>
.padding {
padding-left: 2px;}
</style>
// Below line will work now
<p class="padding">This text has a left padding of 2 cm.</p>
You can use a style block and/or inline css like this:
.HTMLBody = "<style type='text/css'> li.padded {margin-left:70px}; p.padded {margin-left:100px};</style>" & _
"<p>Paragraph 1</p>" & _
"<p>Paragraph 2</p>" & _
"Products are evaluated for performance by family" & _
"<ul><li class='padded'>List item 1</li>" & _
"<li style='margin-left:50px'>List item2</li>" & _
"</ul><p>Paragraph 3</p>" & _
"<p>Paragraph 4</p>" & _
"<p class='padded'>Paragraph 5</p>"
Single quotes and double quotes are more or less interchangeable in HTML, so use single quotes there to avoid having to deal with any escaping for your VBA string building.
Note you're missing <ul>
or <ol>
around your li
items
This did exactly what I needed. Added indented bullet points and removed the line break between the "Products" line and the first list item line.
With xOutMail
.To = xMailAddress
.CC = xMailAddress2
.BCC = ""
.Subject = subj
.HTMLBody = "<html> <head> <style> li.padding { margin-top: -10px; } </style> </head>" & "<p>Operations Leadership,</p>" & _
"<p>An inventory performance summary of your submitted IOM requested products is attached. The IOM Summary tab displays the families that are approved or denied based on whether they met the minimum performance turn threshold.</p>" & _
"Products are evaluated for performance by family<br>" & _
"<ul><li class='padding'>Approved products will be scheduled the same as before, based on forecast availability and prioritized by tier productivity<br>" & _
"<li>Denied products are due to a minimum turn threshold of productivity that is not met" & _
"</ul><p>Attached is an inventory performance report based on the family of products that are requested in the associated IOM. This includes your turn and tier performance, inventory and sales information, the minimum turn threshold and national rank for your territory and decision of Yes/No for approval.</p>" & _
"<p>In addition - we have included three tabs that provide potential opportunities for redeployment within your territory. Each tab report shows your productivity in each family: by account, by demand model (SISO) and evaluating loose shelf inventory and/or inventory contained in sales team and sales associate locations.</p>" & _
"<p>For those product families where the turn threshold is not met, (NO in column J) please review the performance metrics. Utilizing the 3 tabs, evaluate the productivity of the identified Parked account turns, site demand model kit delta and misc inventory locations that carry this product family and work to reallocate / rebalance the inventory to meet the need of this particular IOM.</p>"
.Attachments.Add attch
.Display '.Send
End With
Without testing your full code, I just distilled it down to rendering the proper HTML to prove it works. Here is the code that should do it:
Dim html As String
html = "<html> <head> <style> li.padding { padding-left: 2cm; } </style> </head>"
html = html & "<p>Operations Leadership,</p>" & _
"<p>An inventory performance summary of your submitted IOM requested products is attached." & _
"The IOM Summary tab displays the families that are approved or denied based on whether they met the minimum performance turn threshold.</p>" & _
"Products are evaluated for performance by family" & _
"<li class='padding'>Approved products will be scheduled the same as before, based on forecast availability and prioritized by tier productivity</li>" & _
"<li class='padding'>Denied products are due to a minimum turn threshold of productivity that is not met</li>" & _
"<p>Attached is an inventory performance report based on the family of products that are requested in the associated IOM. " & _
"This includes your turn and tier performance, inventory and sales information, " & _
"the minimum turn threshold and national rank for your territory and decision of Yes/No for approval.</p>" & _
"<p>In addition - we have included three tabs that provide potential opportunities for redeployment within your territory. " & _
"Each tab report shows your productivity in each family: by account, by demand model (SISO) and evaluating loose shelf " & _
"inventory and/or inventory contained in sales team and sales associate locations.</p>" & _
"<p>For those product families where the turn threshold is not met, (NO in column J) please review the performance metrics. " & _
"Utilizing the 3 tabs, evaluate the productivity of the identified Parked account turns, site demand model kit delta and misc inventory " & _
"locations that carry this product family and work to reallocate / rebalance the inventory to meet the need of this particular IOM.</p>"
html = html & "</body> </html>"
Open "c:\cdh\foo.html" For Output As #1
Print #1, html
Close #1
And to give you some confidence that it does indent, this is what the rendered HTML looks like in a browser:
Hard to guess what the issue was without seeing the style applied in the actual VBA, but give this a run and see if it works in lieu of your approach of manual bullets and indentation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.