Solved

How do I send email from Foxpro 9 in windows 7 Pro 64 bit (outlook is installed)

Posted on 2015-01-23
8
522 Views
Last Modified: 2015-01-29
I have a FOXPRO/CDO snippet that works perfectly fine on xp pro as long as the windows component SMTP mail service is installed, but fails with a sendusing configuration not valid in windows 7 pro 64 bit. I looked at the net for solutions, but there was a lot of contradictory postings. I think the reason its not working is that CDOSYS.DLL doesn't work if Outlook 2007 or higher is installed on the workstation. I do have an ASP object called SMTP that shows up under IIS manager.

So has anybody sent email from VFP in a different way ? E.g by calling .net routines?
Any comments about does this work using RDO (redemption) or WestWind)
0
Comment
Question by:Peter Heinicke
8 Comments
 
LVL 29

Accepted Solution

by:
Olaf Doschke earned 300 total points
ID: 40568004
I already answered your private message about this, but it's good you ask public, you may get other answers.

For mails I used Outlook.Application automation and BLAT, way back I got CDO code working, too, but don't use it productive. Googling a bit here's an overview what products install CDO: http://support.microsoft.com/kb/171440/en-us
It has your problem of using Outlook 2007 mentioned, too. Maybe follow the link to http://www.microsoft.com/downloads/details.aspx?FamilyID=2714320D-C997-4DE1-986F-24F081725D36

There are very many ways to mail and they are all listed in the foxpro wiki http://fox.wikis.com and Craig Boyd also made extensive blog article about it. There also is a solution without any requirements posted in Atoutfox, but not speaking french, I don't find it. AFAIK it was very low level code and still depended on winsock.

Bye, Olaf.
0
 
LVL 41

Assisted Solution

by:pcelba
pcelba earned 200 total points
ID: 40568114
CDO should be everywhere independently on Outlook version. I works for me on W7/64 with Office 2010 installed. It also works under other OS configurations. I did not find a configuration under which it could fail...

The code to send a message with ZIP attachment is following:
PROCEDURE SendDataTransfer
LPARAMETERS lcDestination, lcSender, lcSMTP, lcUser, lcPwd, lcZIPFile, lcError

*Updated from http://www.paulsadowski.com/WSH/cdo.htm

LOCAL cdoSendUsingPickup, cdoSendUsingPort, cdoAnonymous, cdoBasic, cdoNTLM, objMessage, llSuccess

LOCAL loEx AS Exception

cdoSendUsingPickup = 1 &&Send message using the local SMTP service pickup directory. 
cdoSendUsingPort = 2 &&Send the message using the network (SMTP over the network). 

cdoAnonymous = 0 &&Do not authenticate
cdoBasic = 1 &&basic (clear-text) authentication
cdoNTLM = 2 &&NTLM

TRY
objMessage = CreateObject("CDO.Message") 
objMessage.Subject = "Testing e-mail " + TTOC(DATETIME())
objMessage.From = lcSender
objMessage.To = lcDestination 
objMessage.TextBody = "This is some sample message text.." + CHR(13) + CHR(10) + ;
            "It was sent using SMTP authentication."
objMessage.AddAttachment(lcZIPFile)

*==This section provides the configuration information for the remote SMTP server.

objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 

*Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = lcSMTP

*Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

*Your UserID on the SMTP server
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = lcUser

*Your password on the SMTP server
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = lcPwd

*Server port (typically 25)
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 

*Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = .F.

*Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

objMessage.Configuration.Fields.Update

*==End remote SMTP server configuration section==

objMessage.Send

llSuccess = .T.

CATCH TO loExc
  lcError = TRANSFORM(loExc.ErrorNo) + " " + loExc.Message
ENDTRY

RELEASE objMessage

RETURN llSuccess

Open in new window

Calling sample:
lcErrorMsg = ''
IF SendDataTransfer("destination@domain.xxx", "sender@domain.xxx", ;
"smtp.domain.xxx", "username", "password", "d:\path\attachment.zip", @lcError)
  *-- Success
ELSE
  *-- Error
  WAIT WINDOW "Error: " + m.lcError
ENDIF

Open in new window

Note that the code uses clear text authentication. Other ways would need some additional testing.
0
 
LVL 2

Expert Comment

by:GEOFS
ID: 40568190
I started using a VFP library called VFPEXMAPI.FLL when I ran into problems with different versions of Outlook, and have been using it ever since.  You can read about it here:

http://www.sweetpotatosoftware.com/spsblog/2006/10/12/VFPExtendedMAPI.aspx
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 40568222
The KB article I posted earlier was last reviewed 2011, but it suggests CDO is no system component and only comes with other software. Also it says CDO does not come with Office 2007. So there can be situations you don't find it installed on a system. The link I quoted will give you an installation.

Anyway, I find Outlook automation quite simple and as you have it, why not use it?

#DEFINE olMailItem   0
loOutlook   = CREATEOBJECT('Outlook.Application')
loMail = loOutlook.CreateItem( olMailItem )
loMail.To = "someone@example.com"
loMail.Subject="the subject"
loMail.Body ="This is the mail text" && also see HTMLBody and RTFBody and Bodyformat
loMail.Send() && or loMail.Display()

Open in new window

SMPT server, pass, etc. is configured in OL, this is using the main OL account, if you want to send from one of many accounts, you need to logon to the MAPI namespace, but for my purposes this is totally sufficient. For Attachments loMail has an Attachment collection, of course starting empty. Use loMail.Attachments.Add(). You also have CC, BCC, Importance, etc.

If there wasn't the safety requirements at some corporations, you could use this everywhere Outlook is used. As you have that under your control it's easy enough to allow your own applications to automate outlook without any variant of Redemption, by configuring the Outlook behaviour for programmatic usage in it's security center options.

Bye, Olaf.
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 40569284
Just a remark: EE seems faster than ever in marking questions as neglected. As far as I found this is already done after 12 hours with no expert response. The question has answers, makes me wonder a bit.

And a test: We'll see, if a fresh post changes the question status again.

Bye, Olaf.
0
 
LVL 2

Expert Comment

by:GEOFS
ID: 40569789
I used to use Outlook automation as described by Olaf and it was simple to implement.  However, as I recall, we ran into difficulties with the CREATEOBJECT method when Outlook was updated, and I think there may have been other issues, too.  That's why I switched to VFPEXMAPI.FLL.  It doesn't seem tp care which version of Outlook is installed.
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 40570041
Geofs,

you will only have problems with outlook security and/or with outlook not installed as desktop application, but using the Webapps of Office 365. That's all.

Outlook security can be configured, if you're not limited by group policies or that setting is handled by an exchange server.

Office 2007 surely isn't a problem, I can also still automate Outlook 2013 in the same manner, as I have both the Cloud Office365 and local installations. Configuring desktop outlook with the office 365 exchange server, all my Mails are in both local pst file and in the cloud, outlook is automatable and I can make use of all cloud advantages.

Bye, Olaf.
0
 

Author Closing Comment

by:Peter Heinicke
ID: 40578174
Key thing to note is that there are a multitude of ways to do this, you don't have to buy westwind just for this purpose.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PC not downloading updates 9 51
hardrive and reformat 5 81
Unknown Windows 7 64-bit Screen Appearance 5 37
Open Encryption Software Advice needed 4 49
Article by: Lee
Windows 7 Ultimate and Enterprise (and 2008 R2) introduced a new feature you may not be aware of - Boot from VHD.   Boot from VHD (or what Microsoft refers to asNative Boot allows you to install Windows to a VHD (Virtual Hard Disk) file that is t…
OfficeMate Freezes on login or does not load after login credentials are input.
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

816 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

11 Experts available now in Live!

Get 1:1 Help Now