Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

outlook automation, foxpro set font on a variable in the body

Posted on 2014-11-11
9
Medium Priority
?
356 Views
Last Modified: 2014-11-12
Looking to set the font type of  Courier New on a variable

      This.oOutlookEmailMessage.Body = pcBody
0
Comment
Question by:dc070994
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 43

Expert Comment

by:pcelba
ID: 40437628
You have to use HTML message format. Look for the example here: http://msdn.microsoft.com/en-us/library/office/ff869979(v=office.15).aspx

olFormatHTML = 2

And the message in Courier New font could contain this HTML text:

<html>
<body>
<p style="font-family:'Courier New'">This is your text in Courier New font.</p>
</body>
</html>

More info: http://www.w3schools.com/tags/tag_font.asp
0
 

Author Comment

by:dc070994
ID: 40437841
oOutlook = CreateObject("cusOutlookAutomation")
oOutlook.show()
oOutlook.New
oOutlook.SetTo('&lc_address','&lc_address2')
oOutlook.SetSubject(psubject)
oOutlook.SetBody(pmessage)

IF !EMPTY(pattachment)
      oOutlook.AddAttachment(pattachment)
ENDIF

oOutlook.send
RELEASE oOutlook


Function SetBody(pcBody)

This.oOutlookEmailMessage.Body = pcBody

EndFunc

I need to know how to force the variable pcBody to appear In Courier New 9pt. in the messageobx,
0
 
LVL 2

Expert Comment

by:GEOFS
ID: 40437874
You could try entering or copying the body text to a textbox with the properties you want, then using that as the source of the Body property:

    Thisform.txtTextbox.Font = "Courier New"
    Thisform.txtTextbox.Value = "Hello world!"
    This.oOutlookEmailMessage.Body = Thisform.txtTextbox.Value
0
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
LVL 2

Expert Comment

by:GEOFS
ID: 40437882
Sorry, the first line of my sample code should refer to FontName instead of Font.
0
 
LVL 43

Accepted Solution

by:
pcelba earned 2000 total points
ID: 40438087
Use following function:
Function SetBody(pcBody)

This.oOutlookEmailMessage.BodyFormat = 2
This.oOutlookEmailMessage.HTMLBody = [<html><body><p style="font-family:'Courier New'">] + pcBody + [</p></body></html>]

EndFunc

Open in new window

The FoxPro MessageBox cannot display Courier New font easily - it depends on Windows settings.
0
 
LVL 2

Expert Comment

by:GEOFS
ID: 40438167
Is there some problem with displaying Courier New in a textbox?
0
 
LVL 43

Expert Comment

by:pcelba
ID: 40438275
No, not at all but how is your question related to Outlook automation?

Your command:
 This.oOutlookEmailMessage.Body = Thisform.txtTextbox.Value

sets just the text value without any formatting. FoxPro does not know what everything you would like to do...
0
 
LVL 2

Expert Comment

by:GEOFS
ID: 40438438
I thought that perhaps some of the basic formatting might be carried from the textbox to the email along with the text.  I remembered seeing a similar suggestion somewhere and thought it might be worth a try.  Admittedly, it's in the realm of grasping at straws.
0
 

Author Closing Comment

by:dc070994
ID: 40438483
Thank you very much, this is exactly what i needed, Much appreciated
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is about my first experience with programming Arduino.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question