Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to send email in HTML format within VFP6 1

Status
Not open for further replies.

VictorFRodriguez

Programmer
Jan 20, 2001
51
DO
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.

CREATEOBJECT("Outlook.Application")
objNameSpace = objOutlook.GetNameSpace("MAPI")
objNameSpace.Logon(,,.T.,.F.)
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
 
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:

Code:
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
       .Display
    End With

End Sub

Hope this helps.

Dave Dardinger
 
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
 
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
 
Victor,

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
 
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>' + ;
'</BODY></HTML>'
loMI.Recipients.Add('anemail@address.net')
loMI.Subject = 'Test1'
loMI.Send
RELEASE loMI,loApp


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!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top