Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending emails from vfp appication

Status
Not open for further replies.

T883

Programmer
Nov 2, 2016
7
US
I've been sending emails with pdf's attached for over 3 years using gmail - till last week they just stopped working. After researching other people's comments I switched to Yahoo email and it worked for 2 days and now it no longer works. I've been using the "cdo2000" code for years. Is there another or better way?? This is basically my current program: I keep getting error 1429 along with either 187 or 191

thanks for any help and/or guidance!

Code:
FUNCTION send_email
loMail = NEWOBJECT("Cdo2000", "Cdo2000.fxp")
WITH loMail
   .nServerPort	= 465
   .lUseSSL	= .T.
   .nAuthenticate	= 1

   .cServer   = "smtp.mail.yahoo.com"
   .cUserName = "username@yahoo.com"
   .cPassword = "17digitpassword"
   .cFrom     = "username@yahoo.com"
   .cTo       = "recipient@whatever.com" 
   .cSubject  = "statement"
   .cAttachment = SYS(5)+CURDIR()+'pdfs\'+ALLTRIM(pdf_name)
ENDWITH

IF loMail.Send() > 0
  FOR i=1 TO loMail.GetErrorCount()
          ? i, loMail.Geterror(i)
  ENDFOR
ENDIF
  loMail.ClearErrors()
RETURN
 
Well, if you used bereznikers code, at some point you don't just have to specify your mail address, but also your mail server. Eg it could be mail.hostedaccount.com, or as Berezniker has written in his sample usage code: loMail.cServerName = "mail.whatever.com"

Mail server access is not like ftp server access, where anyone could connect with his mail address as login in contrast to anonymous FTP.

If you use DennisTheOldOne@HostedAccount.com, you surely sent to mail.HostedAccount.com or similar. Instead of mail it could also be smtp, securesmtp, pop, imap or whatever combination. Since google also offers domain hosting, you may have a domain associated with smtp.gmail.com or imap.gmail.com, so you may not be rejected to use the gmail mailserver at first, but if HostedAccount.com is not a domain hosted by google, your mail server surely will be something else.

In regard to sending the same mail from whatever mailadress to a google mail address you might get blacklisted, and that may have nothing to do with any mailserver, simply because of receiving the same mail multiple times. But typical blacklisting doesn't happen just because of that, but because you send the same mail to multiple gmail accounts. Then it doesn't matter if you do so programmatically or via some mail client. But we still are not at the bottom of which mail server you used. If you think any mail server will do and send mails from DennisTheOldOne@HostedAccount.com to whomever@gmail.com via smtp connection to smtp.gmail.com, surley gmail will blacklist you.

Bye, Olaf.


 
This is getting somewhat confusing.

Without paying attention to the replier's name, I started to answer Dennis' (dkean4) post above, only to look more closely and find that the post was not from the original poster: T883

T883 - let us know if our suggestions/advice has help you solve your problem.
If not, tell us what you have tried.

JRB-Bldr





 
Olaf,

I gave the proper Email address to Berezniker's SendMail as well as the domain name and the authentication. I fixed that little Berezniker puppy and it sends emails everywhere, as I request. Nice little puppy. I have since sent 100+ repeat Emails to several of my own alternate Hosted Email addresses (Which I am not publishing here for obvious reasons). The only thing I did was to send the same Email 5-10 times to a Google Email account and that is the end of it.

Clearly, DennisTheOldOne@HostedAccount.com is a bogus email address. I can send Emails all day long, but Gmail is the only problem I have had to date...



Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
dkean4 said:
And now I cannot send any emails to that account, any more from my Email account

Dennis - the reason I got (and still am) confused is that I can't tell if you are offering suggestions/advice to the original poster ( T883 ) about what they can do to resolve their issue or if you are asking a new, different question.

A number of us have already suggested that T883 quit trying to do Business Emailing in an un-professional manner and that they should set up to use an email server different than Google.

T883 - Good Luck,
JRB-Bldr


 
Mike Gagnom,

Thanks for the Blacklist URL...


Dennis





Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
this information is all a bit overwhelming - but I'm still trying to make this work!

I gave up on google, and yahoo and tried using the company's ISP server - comcast.
It seems to send one email then just starts to record the 1429 error code. My program simply scans a table containing the "send to" email addresses and a pdf filename for the attachment - and then sends to each one. - and yes I tried sending without the attachments with no better results - the server and sender info is hard coded. I even called tech support at comcast for help thinking the server needed more info and basically they said it's not their problem since normal email procedures via the browser works fine. They suggested I download Outlook and set up a new outlook account - which I did and this doesn't work either. Outlook seems to want TSL vs SSL security - but I don't know how to set that up in my program.

I'm getting very frustrated - this should not be so hard to do!
 
Your last report explains a lot. CDO, especially CDO.Configuration has valid info on connection to your ISP mailserver, when it already is configured by an outlook account. Or in other words: When sending through CDO.Message you depend on OS mail setttings being correct for CDO.Configuration. It's easier to automate a mail client and do so via either outlook.application with it's createitem(olMailItem) or via MAPI, not using CDO.Message.

And if you depend on a secured connection several ISPs have separate mail servers for that, i.e. securesmtp.t-online.de vs smtp.t-online.de for german t-online mail accounts. And as already stated a few times overall in the thread, you can't just use any mail server for sending your mail, you'll have to use the mailserver your ISP or hoster provides, the mail server maintaining your mail account also as receiving "mailbox". Seems the secured connection via TSL is the factor, which changed. You typically just have to provide the needed port and mail server and not do anything special about SSL or TSL or even certificates. Comcast must be able to tell you login creddentials and configuration.

normal email procedures via the browser works fine
Haha, very funny. Browser access to mail needs no such mailserver connections. It's working self contained, i.e. a web interface to mails surely makes his own connections to the comcast mailserver, but that's all working internally, the mails going to your company all come through the web interface then. Makes me wonder why you say the mail sending procedure has worked so far, you never really made contact to the mailserver then, you only made contact to a webmail interface.

Bye, Olaf.
 
below is my new code (copied from some of the above ideas)- which produces the following error message.
(trying to test by sending from company's comcast email to my own gmail address)

Code:
OLE:IDispatch exception code 0 from CDO.message.1: The transport failed to connect to the server.


Local iMsg,iConf
Declare SHORT InternetGetConnectedState In wininet.Dll;
    INTEGER @lpdwFlags, Integer dwReserved

lConnect=displayState()
If lConnect
    iMsg = Createobject("CDO.Message")
    iConf = Createobject("CDO.Configuration")
    Flds = iConf.Fields

  With Flds
    .Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2
    .Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = 'smtp.comcast.net'
    .Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] = 587

		* Passing SMTP authentication 
.Item ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")[/URL] = 1 &&basic authentication 
.Item ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusername")[/URL] ="companyemail@comcast.net" 
.Item ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendpassword")[/URL] ="password" 
.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpusessl")[/URL] = .t.  &&send using TLS
.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")[/URL] = 60

        .Update()
    Endwith

    With iMsg
        .Configuration = iConf
        .To = "myemail@gmail.com"
        .CC = ""
        .BCC = ""
        .From = "companyemail@comcast.net"
        .Subject = "This is a test"
        .Fields("Priority").Value = 1   && -1=Low, 0=Normal, 1=High
        .Fields.Update()
        .TextBody = "This is the body text"  && Plain text
       * .AddAttachment( "C:/" + lcFilename) && Valid filename	
        .Send()
    Endwith
    iMsg = .Null.
    iConf = .Null.
    Flds = .Null.
Else
    Messagebox("Could not send the message, you internet connection is down.")
Endif
Procedure  displayState
Local lConnected
lConnected = .F.
lpdwFlags = 0
If InternetGetConnectedState (@lpdwFlags, 0) = 1
    lConnected = .T.
Endif
Return lConnected
Endproc
 
T883 said:
They suggested I download Outlook and set up a new outlook account - which I did and this doesn't work either. Outlook seems to want TSL vs SSL security - but I don't know how to set that up in my program.

I'd recommend that you get it working with Outlook or Thunderbird (free to download) FIRST so that you can confirm the settings needed with the email server. If you have not gotten it to work with a 'standard' email client, then using those same settings in your VFP code is not very likely to work.

Call Comcast support and have them 'walk you through' the email client setup.
And/or go to:

Once you get the settings correct and working in a 'standard' email client, then you can consider using them in your VFP application.

Good Luck,
JRB-Bldr
 
Not sure, what is more recent info, but for example this suggests not using SSQL via smtp.comcast.net: This is what comcast provide themselves: Notice you use port 587, which is recommended, but is smtp, not smtpS (secured via SSL), for SSL access you seem to need to use port 465 in regard to that specs.

As essence I second jrbbldr, get your mail access working with a mail client, then you know how and what to configure.

Bye, Olaf.
 
Success finally! - or at least so far - ran the program 3 times and it worked each time. Basically I used the code above (using microsoft/cdo/configuration) with port 465 - which is what I was originally using with the "cdo2000" procedure. So now I'm no longer using CDO2000 - maybe this was the problem all along?

So the only detail is how to capture a meaningful error message if it fails. This code simply connects or not - if it fails, is there a way to determine why it failed?

thanks again to all who responded!
 
T883

Code:
#Define CRLF Chr(13)+Chr(10)
#Define cdoSendUsingPickup 1
#Define cdoSendUsingPort 2
#Define cdoAnonymous 0
#Define cdoBasic 1 && clear text
#Define cdoNTLM 2 && NTLM
&& Delivery Status Notifications
#Define cdoDSNDefault 0 &&None
#Define cdoDSNNever 1 && None
#Define cdoDSNFailure 2 && Failure
#Define cdoDSNSuccess 4 && Success
#Define cdoDSNDelay = 8 &&Delay
#Define cdoDSNSuccessFailOrDelay 14 &&Success, failure or delay
Local objMsg,objConf,objFlds
Store Null To objMsg,objConf,objFlds
objMsg = Createobject("CDO.Message")
objConf = Createobject("CDO.Configuration")
objFlds = objConf.Fields
With objFlds
	.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] =
	cdoSendUsingPort
	.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] =
	2525
	.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] =
	"mail.carvertechnologies.com"
	.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")[/URL]
	= cdoBasic
	.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusername")[/URL] =
	"mike.gagnon@carver.com"
	.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendpassword")[/URL] =
	"moutarde"
	.Update
Endwith
strBody = "This is a sample message." + CRLF
strBody = strBody + "It was sent using CDO." + CRLF
With objMsg
	.Configuration = objConf
	.To = "mgagnon23@hotmail.com"
	.From = "me@my.com"
	.Sender = 'Me'
	.Subject = "This is a CDO test message"
	.TextBody = strBody
	&& use .HTMLBody to send HTML email.
	*.Addattachment "c:\temp\Scripty.zip"
	.Fields("urn:schemas:mailheader:disposition-notification-to") =
	"me@my.com"
	.Fields("urn:schemas:mailheader:return-receipt-to") = "me@my.com"
	.DSNOptions = cdoDSNSuccessFailOrDelay
	.Fields.Update
	.Send()
Endwith

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
I guess I spoke to soon about success - I tested with sending 5 emails (to myself) running the program 3 times without fail - but when I put the program into production sending emails to our actual customers - it seems to send a few then just stop sending. Beats the heck out of me why this is happening!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top