Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CDOSYS sending email
Message
From
06/10/2005 12:40:55
 
 
To
05/10/2005 11:53:49
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01056325
Message ID:
01056828
Views:
26
Do you receive an error? Is the email sitting in the outbox? I used cdo for awhile and then it quit working unless I specified the smtp server which was not possible because we have hundreds of customers with their own smtp server. I switched to just sending via the default email client installed on every machine instead. The code that worked for me if I specified the smtp server was:
loConfig = CREATEOBJECT('CDO.Configuration')  
loCdoMessage = CREATEOBJECT("CDO.Message")  
loCdoMessage.Configuration = loConfig  
loCdoMessage.From = "myemailadress@email.com"  
loCdoMessage.To =  "myemailaddress@email.com"  
loCdoMessage.HtmlBody = "Body text"  
*loCdoMessage.Addattachment("c:\file.doc")  
loConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2  
loConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "hereIenteredmysmtpserver"  
loConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25  
loConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60  
loConfig.Fields.Update  
loCdoMessage.Send()  
What we use now is:
* Created from Rick Strahl's example code online at:
*  http://www.west-wind.com/Articles.asp
*
=sendemail('youremailadress@email.com','Subject Line','Text body of message')
return



FUNCTION sendemail
LPARAMETERS tcRecipient,tcSubject,tcBody

RETURN GoUrl("mailto:" + tcRecipient + ;
             "&Subject=" +STRTRAN(UrlEncode(tcSubject),"+"," ") +;
             "&Body=" + STRTRAN(UrlEncode(tcBody),"+"," "))


*----------------------------------------------------------------
FUNCTION GoUrl(tcUrl, tcAction, tcDirectory, tcParms)

IF EMPTY(tcUrl)
   RETURN -1
ENDIF

IF EMPTY(tcAction)
   tcAction = "OPEN"
ENDIF

IF EMPTY(tcDirectory)
   tcDirectory = SYS(2023) 
ENDIF

IF EMPTY(tcParms)
   tcParms = ""
ENDIF

DECLARE INTEGER ShellExecute ;
    IN SHELL32.dll ;
    INTEGER nWinHandle,;
    STRING cOperation,;
    STRING cFileName,;
    STRING cParameters,;
    STRING cDirectory,;
    INTEGER nShowWindow

DECLARE INTEGER FindWindow ;
   IN WIN32API STRING cNull,STRING cWinName

RETURN ShellExecute(FindWindow(0,_SCREEN.caption),;
                    tcAction,tcUrl,;
                    tcParms, tcDirectory,1)

*------------------------------------------------------------------
Function UrlEncode( tcValue, llNoPlus )

LOCAL lcResult, lcChar, lnSize, lnX
lcResult=""

FOR lnX=1 to len(tcValue)
   lcChar = SUBSTR(tcValue,lnX,1)
   IF ATC(lcChar,"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") > 0
      lcResult=lcResult + lcChar
      LOOP
   ENDIF

   IF lcChar=" " AND !llNoPlus
      lcResult = lcResult + "+"
      LOOP
   ENDIF

   *** Convert others to Hex equivalents
   lcResult = lcResult + "%" + RIGHT(transform(ASC(lcChar),"@0"),2)
ENDFOR 
RETURN lcResult
>I am using the CDOsys code made by Craig SPS and it works fine on my Windows 2000 workstations.
>I sent it to the end user and they are not sending out email. They do not get and fail nor success
>it is as if the CDOsys is not even being called. It is the exact same compiled exe file they & I am running.
>The only difference is they are running XP.
>
>Any thoughts would be greatly appreciated.
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Reply
Map
View

Click here to load this message in the networking platform