Solved

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

Posted on 2014-11-11
9
332 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
  • 4
  • 3
  • 2
9 Comments
 
LVL 41

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
 
LVL 2

Expert Comment

by:GEOFS
ID: 40437882
Sorry, the first line of my sample code should refer to FontName instead of Font.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 41

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 41

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now