Font size changed when email is sent - html

I am facing the following issue: when I send out a automated email the font size changes from 10 to 11. See below the code I am using:
With OutlookMailitem
.To = toEmail
.CC = ccEmail & ";" & ccEmail2 & ";" & ccEmail3
.Subject = "Submit your Timesheet"
.HTMLbody = "<p style='font-family:arial;font-size:13'>" & "Hey " & toName & "," & "<br/>" & "<br/>" & "We noticed your timesheet is still open. Please submit your timesheet each Monday before 12PM. If you face any issues, do let us know." & "<br/>" & "<br/>" & "Best," & signature
.Send
End With
Any idea what is causing this? Many thanks in advance.

Could you try using px.
<p style='font-family:arial;font-size:13px'>

You missed to add "px" or the unit that you want before the font-size, if this doesn't work... maybe another function is overwriting your styles, then try to add !important after the font-size: 13px like this:
<p style='font-family:arial;font-size:13px!important;'>
!important shall take priority over any other style that is applied.

Related

How to Change .HTMLBody Font Size to 12 pt?

I am trying to change the font size of certain parts of my email to size 12pt.
11pt and 13pt both work. When trying to set 12pt font it comes out at size 10pt.
Here is a portion of my code:
.HTMLBody = "Hello All,<br><br>" & _
"<B><U><font style=""font-size:13pt"">Incidents:</B></U></font><br><br>" & _
ES11Text & _
"<B><U>Non Intervention Incidents:</B></U><br><br>" & _
NonInterventionText & _
"<B><U>Hand-off:</B></U><br><br>" & _
"N/A<br><br>" & _
"<B><U>Escaltions:</B></U><br><br>" & _
Escalations & _
"Regards,<br>" & _
Signature
I figured it out. In my code to generate an email I wanted to include my signature at the bottom so I set a string equal to OutMail.HTMLBody before doing anything else and then concatenate that string to the end of my email which will add my signature. Doing this is what srews it up. If I don't include the signature, Times New Roman 12pt font works... Still doesn't make sense to me.

Create an email body in HTML that includes information from an object

I have a VBA object, aPosition.
I am trying to display information aPosition.something in an email.
My code gives me a syntax error.
strBody = "<HTML>" strBody & "<BR> & <p style='font-family:Trebuchet MS,sans-serif;font-size:22'>Equity position in sell: " & aPosition.SEC_NAME & " (" & aPosition.ISIN & ")" & " now in "& aPosition._RANKING" </p> & _
" Target Price: " & aPosition.TARGET_PRICE & "<BR>" & _
"<b><span style=""color:#C00000"">We have downgraded</span style=""color:#C00000""></b>" & aPosition.SEC_NAME & "<BR>" & " <U>Clients Impacted:</U><BR>"
You have a few problems when building your string.
First of all, you can use single quotes in your styles to eliminate the possible double-double quotes confusion.
Secondly, you seem to have strBody mixed in there twice for some reason.
Also, whatever aPosition is, you cannot have a property that starts with an underscore (aPosition._Ranking not valid), so I removed just that underscore. (so double check that part)
Try it like this:
strBody = "<HTML>" & strBody & "<BR><p style='font-family:Trebuchet MS,sans-serif;font-size:22'>Equity position in sell: " & aPosition.SEC_NAME & " (" & aPosition.ISIN & ") now in " & aPosition.RANKING & "</p>" & _
" Target Price: " & aPosition.TARGET_PRICE & "<BR>" & _
"<b><span style='color:#C00000'>We have downgraded</span style='color:#C00000'></b>" & aPosition.SEC_NAME & "<BR><U>Clients Impacted:</U><BR>"
The rule of thumb is to make sure you set a well-formed HTML markup to the HTMLBody property, for example, I see the following:
strBody = "<HTML>" strBody & "<BR>
If you want to modify the existing email body you need to paste your HTML pieces after the <body> tag and before the closing </body> tag.

Setting email body background color in a VBA created HTML Outlook email

I have an Excel macro that creates and sends emails. I want to set the background colour to match an inserted image. It is a dark blue shade so I will also look at changing the text to white.
Most searches show results for table background not the entire email body background. Is it possible to change the background of an Outlook email in VBA using HTML Body?
xHTMLBody = "<span LANG=EN>" _
& "<Body style = bgcolor=”#1b1c37”>" _
& "<p class=style2><span LANG=EN><font FACE=Calibri SIZE=3>"
_
& "<p>Dear " + Worksheets("SHeet2").Range("T3") + ",</p></p>
</p>" _
& "<p>The weekly results .</p></p>" _
& "<br>" _
& "<IMG align=baseline border=0 hspace=0 src=cid:myident>" +
",</p></p></p>" _
& "<br>If you have any questions feel free to give me a call
</font></Body></span>"
The code produces an email but "BGcolor" isn't changing anything.
Try the following instead:
"<Body style="bgcolor=#1b1c37">"
or
"<Body style="backgroundcolor=#1b1c37">"
Make sure that you create a well-formed HTML markup. I'd recommend testing your sample HTML markup in Word because Outlook uses it for rendering message bodies.

Sending a filepath hyperlink in Gmail using VBA

I am doing an approval route which will auto generate an email to the user when there is a new entry. Everything works extremely cool till I try to insert a hyperlink to the workbook in the sent email. FYI, I am using Gmail.
This is my code:
With NewMail
.Subject = RequestSubmission.ComboBox1.Text & ":pending your approval"
.From = "****#gmail.com"
.To = "****#gmail.com"
.CC = ""
.BCC = ""
.HTMLBody = "<font size=""3"" face=""Calibri"">" & _
"To whom it may concern,<br><br>" & _
"There is a new request:<br><B>" & _
RequestSubmission.ComboBox1.Text & "</B> is created.<br>" & _
"Click on this link to approve or reject the request : " & _
"Approval or Rejection" & _
"<br><br>Regards," & _
"<br><br>Max</font>"
.AddAttachment RequestSubmission.TextBox2.Text
End With
I believe I missed out something in the HTML body but I could not find it and rectify it. Someone help me please...

Signature needs to be in RTF instead of HTML. Passing in from VB6 to Outlook

I was passing a string of HTML formatted text for a signature in VB6 to Outlook but on certain very old computers with very old versions of outlook it was running into a problem where hypens would start a new line, or if I used the tag to fix it then word wrap would be totally turned off.
I want to try to use RTF instead hoping that this will fix the problem. However I still have that signature that is in HTML and I need to pass it in as a string into Outlook using Rich Text formatting. I can't find any good resources on this or if it is even possible, whenever I try they show up with the escape commands and everything.
My current HTML string:
string = vbCrLf & vbCrLf & "<B><FONT face=Arial color=#365f91 size=2>" & _
strName & "</FONT>" & _
"<FONT face=Arial size=2><BR>" & _
"<I>" & strPosition & "</I>" & _
"</FONT></B><BR/><B><FONT face=Arial size=2>" & _
strAddress1 & "</FONT></B><BR/><FONT face=Arial size=1>" & _
strAddress2 & "<BR>" & strCity & ", " & _
strProvince & ", " & strPostalCode & _
"<BR>" & strCountry & "<BR>Office: " & strPhone & _
"<BR>" & strEmail & "<BR>www.website.com<BR>" & _
" " & _
"<I><FONT face=Arial size=2>" & strImageCaption & "</FONT>" & _
"<BR/><BR/><BR/></I><FONT face=Arial size=1>" & strDisclaimer & _
"</FONT></P>"
Anyone able to help me pass this in as rtf or know of anyway I could do this? Will be very appreciated!
EDIT: Alternatively if anyone knows how to fix the issue with word-wrap/line-breaking hyphens I would love that too.
This can be the RTF template idea, produced by wordpad and slightly altered. I assume you can mixin the VB stuff to replace the variable text.
To get this:
Hello
postion
My‑street
Mystreet 2
My city
My disclaimer
( I don't how to do color in SO markup but in the RTF the first line in RED and My disclaimer is one point smaller)
use this RTF:
{\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl{\f0\fnil\fcharset0 Arial;}}
{\colortbl ;\red255\green0\blue0;}
\cf0\b\fs22 Hello\par
\cf0\b0\i\fs24 postion\par
\i0 My\_street\par
Mystreet 2\par
My city\par
\fs22 My disclaimer\par
\f1\par
}
between My and street I placed a non breaking hyphen, according to the RTF specs. In html the same could be achieved by using
‑