Rob-Nixon


Hi,

I am wondering if it's possible to send an email through Outlook from a FoxPro program.

I found some code:

LOCAL loOutlook as Outlook.Application, ;

loNameSpace as Outlook.NameSpace, ;

loFolder as Outlook.MAPIFolder, ;

loMailItem as Outlook.MailItem

loOutlook = CREATEOBJECT("Outlook.Application")

loNamespace = loOutlook.GetNamespace("MAPI")

loFolder=loNamespace.GetDefaultFolder(olfolderinbox)

loMailItem = loFolder.Items.Add(olMailItem)

WITH loMailItem

.To = "robchnixon@talktalk.net"

.attachments.add(HOME()+"fox.bmp")

.display()

ENDWITH

But it comes up with loads of errors, which as a new FoxPro developer I am not sure how to rectify. The errors I am getting are:

Variable OLFOLDERINBOX is not found

Variable OLMAILITEM is not found

Any help would be greatly appreciated

Regards

Rob




Re: send an email via outlook

MarciaAkins


Rob-Nixon wrote:

But it comes up with loads of errors, which as a new FoxPro developer I am not sure how to rectify. The errors I am getting are:

Variable OLFOLDERINBOX is not found

Variable OLMAILITEM is not found

#DEFINE olFolderInbox 6

#DEFINE olMailItem 0

at the top of your code







Re: send an email via outlook

Alex Feldstein

What you need is to define the constants needed to run Outlook, or better yet, use an INCLUDe file.

Marcia gave you the correct values for your example.

Here you cave a list of constants to use in an include file: outlook.h

http://fox.wikis.com/wc.dll Wiki~OutlookConstants

You can get more info here:

Outlook Automation Part 1: http://weblogs.foxite.com/simonarnold/articles/236.aspx

Outlook Automation Part 2: http://weblogs.foxite.com/simonarnold/articles/270.aspx

Outlook Automation Part 3: http://weblogs.foxite.com/simonarnold/articles/320.aspx