West Wind Internet and Client Tools
wwsmtp run from VFP6 app
Gravatar is a globally recognized avatar based on your email address. wwsmtp run from VFP6 app
  Aug 31, 2019 @ 12:20pm

Have a client running a VFP6 app that needs their emailing piece updated. They don't want to update the entire app to VFP9. So tried to use wwsmtp, but it fails when run from VFP6 environment. Getting SetClrVersion error when run from VFP6. Same code running from VFP9 works fine.

Anyway to get wwsmtp to work from VFP6?

Here is the code:

LPARAMETERS tcsender,tcrecipient,tcsubject,tcmessage,tcattachment,tcmailserver,tcuser,tcpassword,tnport

DO wwsmtp
LOCAL losmtp as wwsmtp, lcmessage
lcmessage = ALLTRIM(tcmessage)
losmtp = CREATEOBJECT("wwsmtp")
loSmtp.nMailMode = 0	&& .net mode.
losmtp.cmailserver = ALLTRIM(tcmailserver)	
losmtp.lUseSsl = .T.
losmtp.cusername = ALLTRIM(tcuser)
losmtp.cpassword = ALLTRIM(tcpassword
losmtp.nserverport = tnport

losmtp.csendername = tcsender
losmtp.csenderemail = ALLTRIM(tcsender)
losmtp.crecipient = ALLTRIM(tcrecipient)
losmtp.ccontenttype = "text/html"
losmtp.csubject = ALLTRIM(tcsubject)

losmtp.cmessage = lcmessage

IF !EMPTY(tcattachment)

llresult = losmtp.sendmail()

Gravatar is a globally recognized avatar based on your email address. re: wwsmtp run from VFP6 app
  Rick Strahl
  Aug 31, 2019 @ 02:51pm

wwDotnetBridge (which is what powers the .NET features of wwSmtp) was not designed for VFP 6. A quick check verifies that some of the COM APIs required to bootstrap .NET don't exist in VFP 6. So the short answer is: No you can't.

You may however be able to use the non-.NET API with wwSmtp by setting .nMailMode = 2 which uses the older classic mode that uses raw Win32 API code. However that mode doesn't support TLS/SSL messages.

I'm not sure if even that works though because again the code is not designed to run on VFP 6. Current versions of all the West Wind tools are designed for VFP 9 only, and we have older versions that work with older versions of VFP. You might want to check on the download pages and see if you are on the latest version that VFP 6 is supported for. If your version is older upgrading to the last supported version may still offer a jump in features.

+++ Rick ---

© 1996-2020