Here is the code for email. Seems to work in xHB using FiveWin 7.01, but it doesn't work with the new FiveWin which makes me think I have something wrong with my make file.
#include "FiveWin.ch"
#DEFINE TRUE .T.
#DEFINE FALSE .F.
function Main()
TestSend()
return nil
Function TestSend()
Local cServer := "smtp.gmail.com"
Local cUserName := "Shipping@mycompany.com"
Local cPassWord := "mypassword"
Local cFrom := "Shipping@mycompany.com"
Local cSubject := DtoC( Date() ) + "-" + Time() + ", SPF Test for EMail"
Local cToAddr := "byron.hopp@gmail.com"
Local cCC := "bhopp@matrixcomputer.com"
Local cBody := "Email to test the SPF information in the EML. This email was authencated using the
Shipping@mycompany.com user name."
Local cAttach := "c:\PdfFolder\Hopp.pdf"
Local cCsvFile := ""
Local lAttachCsv := FALSE
Local cLogFile := ""
McsSendEMail( cServer,cUserName,cPassWord,cFrom,cSubject,cToAddr,cCC,cBody,cAttach,cCsvFile,lAttachCsv,cLogFile )
Return nil
Function McsSendEMail( cServer,cUserName,cPassWord,cFrom,cSubject,cToAddr,cCC,cBody,cAttach,cCsvFile,lAttachCsv,cLogFile )
Local oError := nil
Local nI := 0
Local oEmailCfg := nil
Local oEmailMsg := nil
Local cHtml := '<!DOCTYPE HTML PUBLIC "-/' + '/W3C/' + '/DTD HTML 4.0 Transitional/' + '/EN">'
cHtml += '<HTML><HEAD>'
cHtml += '<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>'
cHtml += '<META name=GENERATOR content="MSHTML 8.00.6001.18783">'
cHtml += '<STYLE></STYLE>'
cHtml += '</HEAD>'
cHtml += '<BODY bgColor=#ffffff>'
cHtml += '<DIV><FONT size=2 face=Courier New>' + cBody + '</FONT></DIV></BODY></HTML>'
Try
oEmailCfg := CreateObject("CDO.Configuration")
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/smtpserver" ):Value := cServer // "smtp.gmail.com"
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value := 465 // was 587
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/sendusing" ):Value := 2 // 1 Pickup, 2 Port, 3 Exchange
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value := TRUE
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value := TRUE // FALSE
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/sendusername" ):Value := cUserName
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/sendpassword" ):Value := cPassWord
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout" ):Value := 10
oEmailCfg:Fields:Update()
Catch oError
MsgStop( oError:Description,"CDO.Configuration - cEMailCfg:Fields:Update()")
End Try
Try
oEmailMsg := CreateObject("CDO.Message")
oEmailMsg:Configuration := oEmailCfg
oEmailMsg:From := cFrom // chr(34) + "shipping@mycompany.com" + chr(34) + "<shipping@mycompany.com>"
oEmailMsg:To := cToAddr // "bhopp@matrixcomputer.com"
oEmailMsg:Cc := ""
oEmailMsg:BCc := ""
oEmailMsg:Subject := cSubject
oEmailMsg:MDNRequested := FALSE
oEmailMsg:HTMLBody := cBody
If File( cAttach )
oEmailMsg:AddAttachment := cAttach
Endif
If lAttachCsv .AND. File( cCsvFile )
oEmailMsg:AddAttachment := cCsvFile
Endif
oEmailMsg:Send()
Catch oError
MsgInfo( "Could not send message" + ";" + ;
"Error: " + TRANSFORM(oError:GenCode, NIL) + ";" + ;
"SubC: " + TRANSFORM(oError:SubCode, NIL) + ";" + ;
"OSCode: " + TRANSFORM(oError:OsCode, NIL) + ";" + ;
"SubSystem: " + TRANSFORM(oError:SubSystem, NIL) + ";" + ;
"Message: " + oError:Description )
End Try
Return nil