Click here to Skip to main content
16,017,502 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
We have below code to trigger Outlook email:

t OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olmailitem)
                
With EmailItem
    .To = sMyOpsStaffNO
    '.cc = sMyCaseworkerid
                
    .Subject = "RESTRICTED CLIENT"
                
    .body = "Thank you for your Referral Request logged as:= " & sMyCCESMno & Chr(10) _
    & "Case Reference Number:= " & sMyCaseNumber & Chr(10) _
    & "Employer ERN:= " & sMyERN & Chr(10) _
    & "Employer Name:= " & sMyERNName & Chr(10) & Chr(10) _
    & "I have identified that the referral submitted contained an error therefore we are rejecting the referral sent to us for the following reason(s):-" & Chr(10) & Chr(10) _
    & "###########################################################################################################" & Chr(10) _
    & sResp & Chr(10) _
    & "###########################################################################################################" & Chr(10) & Chr(10) _
    & "Many Thanks" & Chr(10) & Chr(10) & Chr(10) & Chr(10) _
    & uName & Chr(10) _
    & "Payment and Services Customer Service Team" & Chr(10) _
    & "E_M_A_I_L_B_L_O_C_K"

    '''.Display
    '''.Save
    EmailItem.DeleteAfterSubmit = True
    EmailItem.send
    
End With


This email triggers with font size 1638. We checked with the outlook setting and the font size is set to 12.

Not sure why this is getting changed with email triggered through above code.

Please advise.

thanks
Parag

What I have tried:

We checked the Outlook font size setting.
Posted
Updated 19-Aug-19 2:48am

Above piece of VBA code is not related to font size, unless you did not show the part which changes it. You should change default font for email: Change the default font or text color for email messages - Outlook[^]

For html body, read this: excel vba - Change HTML email body font type and size in VBA - Stack Overflow[^]
 
Share this answer
 
Quote:
This email triggers with font size 1638. We checked with the outlook setting and the font size is set to 12.

This piece of code send plain text Email, thus don't try to set a font type or size. There is simply not font setting associated with a text mail message, the setting is app related.
The size of font depend on client settings.
You need to use HTML Email in order to allow a font type and size setting on your side.
 
Share this answer
 
v2
It sounds as if you are saying the problem is that you do not change the font but for some reason it gets set to 1638 point font. Is that the problem?

It is interesting that you set only one byte -- Chr(10) -- for the CrLf -- on a Windows OS. Normally Windows OSes expect 2 byte line ending Chr(10) & Chr(13) CrLf.
Why aren't you using Constants.vbCrLf?
I mention this because it could be that there is an odd offset byte thing since Outlook probably expects the document body to be UTF-8 and that is defined as: "UTF-8 is a variable width character encoding capable of encoding all 1,112,064[1] valid code points in Unicode using one to four 8-bit bytes."*

When you see these odd things in text it is often this type of thing : where a system attempts to make sense of a stream of bytes but cannot.

As a test, maybe remove the Chr(10) entirely and see what you get. If you can attempt to replace them with Constants.vbCrLf.

*from UTF-8 - Wikipedia[^]
 
Share this answer
 
v2
Comments
Member 14562483 19-Aug-19 9:07am    
Thank you for your response.
I'm wondering as this code was working fine and all of sudden font size issue crop up.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900