bndit
asked on
HTML: Using Windows 2010 to save a document as .html but tabs shows as "?"
Dont know much about HTML. I'm trying to create a document (welcome email template) that I'll use with Powershell to send welcome emails. I'm using Word 2010 to create a document and save it as .html. I create the document and saves just fine. It even displays as intended when I open the html file using IE or Firefox. However, when I send the email tab characters show as "?" marks, so I'm not sure what's happening. The piece of the document that I use tabs is something like this:
Any advice? I'm attaching the both Word and Html files
testfile.docx
testfile.html
Username <tab> : <tab> Placeholder00
Password <tab> : <tab> Placeholder01
The piece of html code for the above is this:
<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
margin-left:0in;line-height:normal;background:white'><span lang=EN
style='mso-ascii-font-family:Calibri;mso-fareast-font-family:"Times New Roman";
mso-hansi-font-family:Calibri;mso-bidi-font-family:Calibri;color:#333333;
mso-ansi-language:EN'>Your account information:<o:p></o:p></span></p>
<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
margin-left:0in;line-height:normal;background:white'><span class=GramE><span
lang=EN style='mso-ascii-font-family:Calibri;mso-fareast-font-family:"Times New Roman";
mso-hansi-font-family:Calibri;mso-bidi-font-family:Calibri;color:#333333;
mso-ansi-language:EN'>Username<span style='mso-spacerun:yes'> </span>:</span></span><span
lang=EN style='mso-ascii-font-family:Calibri;mso-fareast-font-family:"Times New Roman";
mso-hansi-font-family:Calibri;mso-bidi-font-family:Calibri;color:#333333;
mso-ansi-language:EN'><span style='mso-spacerun:yes'> </span><span
style='mso-spacerun:yes'> </span><b style='mso-bidi-font-weight:normal'>Placeholder01</b>
(case sensitive)<o:p></o:p></span></p>
<p class=MsoNormal style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
margin-left:0in;line-height:normal;background:white'><span lang=EN
style='mso-ascii-font-family:Calibri;mso-fareast-font-family:"Times New Roman";
mso-hansi-font-family:Calibri;mso-bidi-font-family:Calibri;color:#333333;
mso-ansi-language:EN'>Password<span style='mso-spacerun:yes'> </span>:<span
style='mso-spacerun:yes'> </span><b style='mso-bidi-font-weight:normal'>MMDDYYYY</b><o:p></o:p></span></p>
If I omit the <tab> characters, then the email displays just fine. Any advice? I'm attaching the both Word and Html files
testfile.docx
testfile.html
How are you trying to send it as email using powershell?
'tab' characters are not displayed as tabs in HTML. They may be displayed as just spaces.
I see no <tab> in the html but what I do see is a lot ofmicrosoft style declarations that word is using. e.g. mso-spacerun:yes
Much better to take work out of the equation and do the html in either a web editor (or for this simple exercise) use notepad.
If you want spaces between pieces of text use <pre> </pre>
All of that MS generated garble <grin> can be replaced with...
Username<pre> : </pre> Placeholder00<br />
Password <pre> : </pre> Placeholder01
Much better to take work out of the equation and do the html in either a web editor (or for this simple exercise) use notepad.
If you want spaces between pieces of text use <pre> </pre>
All of that MS generated garble <grin> can be replaced with...
Username<pre> : </pre> Placeholder00<br />
Password <pre> : </pre> Placeholder01
ASKER
I load the html file into a string object
$emailBody = [string](Get-Content C:\temp\myhtmlfile.html)
#Add things to email body
$emailBody = $emailBody -replace "Placeholder00",$something
# send email. Variables have appropriate values
Send-MailMessage -From $From -To $To -Subject $Subject -Body $emailBody -BodyAsHtml -SmtpServer $SmtpServer
oops *word out of the equation, not "work"
Although you may be doing that too :)
Although you may be doing that too :)
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
@QPR...I tried replacing the code you gave me, but like I said I'm not HTML savvy....when I saved the changes and open the file in Firefox, it's all over the place. Is there an online html editor where I can copy my text, format it like I want, and generate the correct html code? I guess Word puts all that extra stuff because I was using a specific font..bold..and such
Why do you have to convert Word to HTML and send? You can either directly send from Powershell or use Mail Merge to send using Word and Outlook directly.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
@Rajitha14 - not sure if I follow....my goal is to have a formatted (bold, font such as Calibri) HTML template (why HTML? Outlook seems to like it better...if there's another way, I'm open to it). I'm converting from Word to HTML because I'm not HTML savvy and Word allows me to make the changes I want (font size, bold, Calibri, etc.) and Save As HTML. Not sure what you mean by "You can either directly send from Powershell"...I'm using powershell to send the email....not familiar with Mail Merge, but dont think that'd be helpful to me as sending this message is part of a powershell script that provisions mailboxes
You are going to have several problems. First, Word creates HTML files that are print instead of screen oriented. That means they are overly complicated with things that other programs don't always understand. Second, Calibri is a common Office font but it is not a common font anywhere else. Third, different versions of Outlook use different HTML rendering engines. Fourth, other email clients like Gmail and Yahoo may not display a lot of your code because they don't allow some of the style settings you are using.
Simple HTML is what is recommended for HTML email. This page shows how different email clients restrict the styles that you can use: http://www.campaignmonitor.com/css/ Note that Gmail and Yahoo to some extent just strip out anything that might break their page.
Simple HTML is what is recommended for HTML email. This page shows how different email clients restrict the styles that you can use: http://www.campaignmonitor.com/css/ Note that Gmail and Yahoo to some extent just strip out anything that might break their page.
ASKER
@QPR - thanks, that gets me a way better Html document...however, the font selection on that online editor are limited...how could I add Calibri to the doc?
<html>
<head>
<title>HTML Online Editor Sample</title>
</head>
<body>
<p>
<span style="font-family: tahoma,geneva,sans-serif;"><span style="font-size: 12px;">Dear Placeholder00:</span></span></p>
<p>
<span style="font-family: tahoma,geneva,sans-serif;"><span style="font-size: 12px;">We are writing to welcome you to . and to tell you how much we are looking forward to you joining our team. You bring experience, knowledge and skills that enhance our capabilities.</span></span></p>
<p>
<span style="font-family: tahoma,geneva,sans-serif;"><span style="font-size: 12px;">Your account information</span></span></p>
<p>
<span style="font-family: tahoma,geneva,sans-serif;"><span style="font-size: 12px;">Username :<strong> Placeholder01</strong> (case sensitive)</span></span></p>
<p>
<span style="font-family: tahoma,geneva,sans-serif;"><span style="font-size: 12px;">Password :<strong> MMDDYYYY</strong></span></span></p>
<p>
<span style="font-family: tahoma,geneva,sans-serif;"><span style="font-size: 12px;">Best Regards,<br />
Human Resources</span></span></p>
</body>
</html>
ASKER
@DaveBaldwin - thanks for the heads up. However, this email is for internal purposes only and will be sent to Exchange mailboxes, so I'm not concerned about the scenarios you mentioned. I totally understand that adding additional fonts can cause problems, and it's not necessary to add Calibri...just would be nice to do so. I can live with the other fonts available on that online editor.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
@Rajitha14 - so you mean replace this string "font-family: tahoma" with "font-family:Calibri" in the html code I provided above?
Yes, so long as the recipient has this font installed on their machine then you are good to go
ASKER
Thanks for the help