Solved

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

Posted on 2014-11-11
9
343 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 42

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 42

Accepted Solution

by:
pcelba earned 500 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 42

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

730 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