Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

How to send email in HTML format within VFP6

How to send email in HTML format within VFP6

There is a code in which you can invoke outlook express to send emails from VFP
But, how can I do to send emails in HTML format//?
The code is this,,, it is not mine, I copied from other person.

objNameSpace = objOutlook.GetNameSpace("MAPI")
objItem = objOutlook.CreateItem(0)
objItem.Subject = "ASUNTO....."
objItem.Body = "Body text message")
objItem.Importance = 2 && importancia

xDocument='C:\archivo.xls'  && Name of the file to attached
objItem.attachments.ADD(ALLTRIM(xDocument),1,1,"")      && attached document

I will appreciate your help
Victor F. Rodriguez
Santo Domingo, Dominican Republic

RE: How to send email in HTML format within VFP6

First of all, it's using Outlook, not Outlook express, so the computer using the automation must have some (relativel recent) version of Outlook on it.  

I believe the property you want is the .bodyformat property.  It can have the values of 'plain text', 'richtext' and 'html'.  Here's the example in my VBAOL10 help file:

Sub NewMail()
'Creates a new Mailitem and modifies its properties

    Dim olApp As Outlook.Application
    Dim objMail As MailItem
    Set olApp = Outlook.Application
    'Create mail item
    Set objMail = olApp.CreateItem(olMailItem)

    With objMail
       .DownloadState = olHeaderOnly
       'Set body format to Rich Text
       .BodyFormat = olFormatRichText
    End With

End Sub

Hope this helps.

Dave Dardinger

RE: How to send email in HTML format within VFP6

If you are using Outlook 2K2, Dave's advice holds true.

However, if you are using Outlook 2K or earlier, you would use the HTMLBody property, ISO the Body property in your original example.

Jon Hawkins

RE: How to send email in HTML format within VFP6

I still do not understand...
where do get those codes
How do I get from a class the commands that can be invoked?
There are many questions that I don't find answer
How do you know or who was the source that taught you how to get those codes?
Do you know the proper code for OUTLOOK EXPRESS...

Victor F. Rodriguez

RE: How to send email in HTML format within VFP6

You might want to check out webconnect and use its classes.  You can find them at 

RE: How to send email in HTML format within VFP6


Outlook Express does not support Automation, so there is no code you can use with it.   That's why it's basically free, it's missing a lot of the bells and whistles they want you to pay for.  

Dave Dardinger

RE: How to send email in HTML format within VFP6

The example shown by Dave Dardinger above is in VB.  In Fox, as you correctly point out you'll need to modify the code to use the codes that the constants (olFormatRichText etc ) represent.  To see these and the rest of the object model, either use the FoxPro Object Browser to examine the Outlook 98 Type Library, or in Word or Excel goto Tools, Macros, Visual Basic Editor.  Then F2 to enter the Object Browser, R-click on the Library drop-down, select 'References' and check the Outlook Library you are using.  You can then select Outlook from the drop-down.

For OL 2K and lower the following should work:

loApp = CreateObject('Outlook.Application')
loMI = loApp.CreateItem(0)   && 0 = 'olMailItem'
loMI.HTMLBody = '<HTML><BODY>' + ;
                '<p>Your HTML Message Here...</p>' + ;
loMI.Subject = 'Test1'

Note that using the HTMLBody property does what you are after.  Simply setting the Body property will default the message back to your current Outlook default editor format.

Best of luck!

Red Flag This Post

Please let us know here why the post below is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close