Hi. I created an app that goes into the database and gets information regarding customer's orders and sends that order information as an HTML email using wwSMTP. When I step through the code in debug mode, all the email sends fine. When I don't step through, only the 1st email will go out, even though it's calling the function to send it each time. What am I doing wrong? It is not throwing an error message. It just isn't sending them out. Can it not handle sending one after another, after another?
#define WWIPSTUFF_SHAREWARE .F.
SET PATH TO ".\classes" ADDITIVE
*** Core classes
SET PROCEDURE TO wwHTTP ADDITIVE
SET PROCEDURE TO wwUtils ADDITIVE
SET PROCEDURE TO wwAPI ADDITIVE
SET PROCEDURE TO wwEval ADDITIVE
***
SET PROCEDURE TO wwSMTP ADDITIVE
LOCAL loSMTP as wwSmtp
loSmtp=CREATEOBJECT("wwSmtp")
loSmtp.cMailServer=ALLTRIM(thisform.txtsmtp.Value)
loSmtp.nTimeout = 25
loSmtp.cSenderEmail=ALLTRIM(thisform.txtemail.Value)
loSmtp.cSenderName=ALLTRIM(thisform.txtname.Value)
loSmtp.cUsername = ALLTRIM(thisform.txtuser.Value)
loSmtp.cPassword = ALLTRIM(thisform.txtpw.Value)
***
SCAN TO FILL DATA for HTML which I store in a memo field (myfile.mfilecontents)
....
ENDSCAN
***
loSmtp.cRecipient= ALLTRIM(thisform.txtemail.Value) && change to cust.email
loSmtp.cSubject="Order #" + ALLTRIM(STR(lnorder))
loSmtp.cMessage=myfile.mfilecontents
loSmtp.cContentType = "text/html"
llResult = loSmtp.SendMail()
IF !llResult
Wait window loSmtp.cErrorMsg
ENDIF
loSmtp.cLogFile = FULLPATH("SmtpLog.txt")
IF !llResult
Wait window oMail.cErrorMsg
ENDIF
Please edit your message and reformat the code with the code option from the menu so we can actually read it. Thanks.
Done. Sorry about that. First timer.
You better check for error messages. Most likely the issue is that your provider doesn't allow you to send messages in quick succession. Check and print the error message on the sends that are failing - I bet it'll be a server generated method that talks about throttling of some sort.
There's no reason that I can see that it shouldn't work for multiple send operations.
To try something different you can also set loSmtp.nMailMode = 0
which sends with the .NET mail client. In general that client is more stable and it might make difference if there is indeed something going wrong in the protocol when sending multiple mails quickly.
+++ Rick ---
Thanks Rick. I have put in the error message and log file catch in the code:
llResult = loSmtp.SendMail()
IF !llResult
Wait window loSmtp.cErrorMsg
ENDIF
loSmtp.cLogFile = FULLPATH("SmtpLog.txt")
IF !llResult
Wait window oMail.cErrorMsg
ENDIF
Is there additional error checking I should be doing? This code above isn't giving me any error messages.
I will try the ``` loSmtp.nMailMode = 0
suggestion.
Thanks
Jill
One more question. I have ```foxpro loSmtp.nTimeout = 25
could this be an issue?
Thank you.
If you're not getting an error message, the server is accepting your email message. IOW, it's getting there... Whatever happens after that is an issue with the server not sending the message properly or blocking it based on SPAM or frequency filters.
As I mentioned many mail providers will not let you send multiple messages back to back very quickly in batch although usually you'll see an error message coming back from the server. Beyond that I don't know. All I can say is this: If it works sending a single message, there's nothing different about sending multiple messages, so there should be no difference with the server.
If you're sending file attachments make sure the files exist.
To test try a few things:
- Use a different mail provider to test with the same code
- Use any multiple send code, but delay the second send by 20-30 seconds
- Switch to nMailMode=0
+++ Rick ---