Solved

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

Posted on 2014-11-11
9
336 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 …
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…

910 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

22 Experts available now in Live!

Get 1:1 Help Now