FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour OLE and fonts used in Outlook - SOLVED
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
OLE and fonts used in Outlook - SOLVED
Posted: Wed Feb 04, 2015 04:51 PM
Hello,

From my application, I send an email using this code :
Code (fw): Select all Collapse
oOutLook   := TOleAuto():New("Outlook.Application")
oNameSpace := oOutlook:GetNameSpace("MAPI")
oMail  := oOutLook:CreateItem(olMailItem)
...
If I send an e-mail in Outlook, my standard font is Calibri 11. But if I send an e-mail from my application to Outlook, the font used is Times New Roman 12.

How can I add an instruction so that my e-mail, send from my application, is in Calibri 11 too?

Thanks in advance for any help.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: OLE and fonts used in Outlook
Posted: Sat Feb 07, 2015 02:52 AM
Michel,

strbody = "<BODY style=font-size:11pt;font-family:Calibri>Good Morning;<p>We have completed our main aliasing process for today. All assigned firms are complete. Please feel free to respond with any questions.<p>Thank you.</BODY>"


http://stackoverflow.com/questions/22200910/change-html-email-body-font-type-and-size-in-vba
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: OLE and fonts used in Outlook
Posted: Sat Feb 07, 2015 12:42 PM

Antonio,

Thanks a lot for your help.

But there is one problem left :

If I use a font like "Times New Roman", then only "Times" is accepted.

I tried to put the font name between quods (I tried double and single quods) but the result doesn't change.

How do we handle spaces in a font name?

Thanks.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: OLE and fonts used in Outlook
Posted: Sun Feb 08, 2015 05:38 AM

Michel,

Please show me your code to see how you have defined it, thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: OLE and fonts used in Outlook
Posted: Sun Feb 08, 2015 11:02 AM
Antonio,

This is the code I use :
Code (fw): Select all Collapse
oMail:HTMLBody := "<html><body style=font-size:" + ALLTRIM(STR(US->UOUTLFTGRT,2,0)) + "pt;font-family:" + ALLTRIM(US->UOUTLFONT) + "><style type=" + CHR(34) + "text/css" + CHR(34) + "> p { line-height: 100%; }</style><p>" + ALLTRIM(FmText) + "</p><p>" + "</body></html>"
US ->UOUTLFONT = the name of the font, defined by the user.
US->UOUTLFTGRT = the size of the font, defined by the user.

If a font like Calibri or Arial is chosen, everything is just fine. If a font is chosen like "Times New Roman", the font used in my e-mail is "Times".

I also tried to add quotes ( CHR(34) ), but the results is just the same.

Thanks.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: OLE and fonts used in Outlook
Posted: Sun Feb 08, 2015 12:34 PM

Michel,

Try with single quotes, Chr( 39 )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: OLE and fonts used in Outlook
Posted: Sun Feb 08, 2015 03:04 PM

I also tried it with single quotes. Same result.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: OLE and fonts used in Outlook
Posted: Sun Feb 08, 2015 05:08 PM

Michel,

This may be obvious, but have you confirmed that the field actually contains "Times New Roman?"

Have you viewed the output HTML from your code?

Also, have you tried hand coding the html instead of using field data?

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: OLE and fonts used in Outlook
Posted: Sun Feb 08, 2015 05:22 PM

There is a HTML interactive editor on this page:

http://www.w3schools.com/tags/tryit.asp ... t_face_css

There you can try out different coding.

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: OLE and fonts used in Outlook
Posted: Sun Feb 08, 2015 08:16 PM

Michel,

As James has pointed, please do a MsgInfo( oMail:HTMLBody ) and post here a screenshot, thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: OLE and fonts used in Outlook
Posted: Sun Feb 08, 2015 10:08 PM
Antonio,

Here is the screenshot you asked for.



The result in Outlook looks like this :



I also tried it with double and single quotes. But the results in Outlook stays the same : "Times" in stead of "Times New Roman".

And to James : I also have tried hand coding the html instead of using field data. But once again, the same results. So, I don't think there is something wrong in my code. It seems a bug to me.

Thanks.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: OLE and fonts used in Outlook
Posted: Mon Feb 09, 2015 06:50 AM

Is this a new version of Outlook? If so, does it only support HTML5?

I see that HTML5 doesn't support the "font-family" syntax anymore. See:

http://www.w3schools.com/tags/tag_basefont.asp

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: OLE and fonts used in Outlook
Posted: Mon Feb 09, 2015 08:45 AM

James,

No, this is Outlook 2010.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: OLE and fonts used in Outlook
Posted: Mon Feb 09, 2015 09:49 AM
Michel,

try

Code (fw): Select all Collapse
style = "..."


EMG
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: OLE and fonts used in Outlook
Posted: Mon Feb 09, 2015 10:49 AM
Yes, yes, yes, Enrico. That is the solution.

Now it's working fine.

So I changed my code into
Code (fw): Select all Collapse
oMail:HTMLBody := "<html><body style=" + CHR(34) + "font-size:" + ALLTRIM(STR(US->UOUTLFTGRT,2,0)) + "pt;font-family:" + ALLTRIM(US->UOUTLFONT) + CHR(34) + "><style type=" + CHR(34) + "text/css" + CHR(34) + "> p { line-height: 100%; }</style><p>" + ALLTRIM(FmText) + "</p><p>" + "</body></html>"
Thank you so much.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Continue the discussion