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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending email with CDO failing after move to the cloud

Status
Not open for further replies.

flpro

Programmer
Sep 18, 2005
16
US
Hello guys,

I have an application on VFP 9, it uses CDO to send emails, the emails starting failing after the networking people put everything on the cloud and I believe they upgraded the email so now it's outlook 365 I believe, I get the below error now when my app tries to send email.

OLE iDispatch exception code 0 from ?: The server rejected the sender address. The server response was: 451 5.7.3 STARTTLS is required to send email (BL0PR02CA0122.namprd02.prod.outlook.com)

This is my current code:

lcSchema = "loConfig = CREATEOBJECT("CDO.Configuration")

WITH loConfig.FIELDS
.ITEM(lcSchema + "smtpserverport") = 25 && 25 or 110 or 587? (SMTP Port)
.ITEM(lcSchema + "sendusing") = 2 && 1 = Send with locally installed SMTP service 2 = Send with SMTP Srvice on Network
.ITEM(lcSchema + "smtpserver") = "smtp.office365.com'
.ITEM(lcSchema + "smtpauthenticate") = 1 && 0 = No Authentication, 1 = Authentication plain text, 2 = Authentication
.ITEM(lcSchema + "sendusername") = 'testusername' && Username
.ITEM(lcSchema + "sendpassword") = 'testpassword' && Password
.UPDATE
ENDWITH

Before it ws sending with smtpauthenticate set to 0 (no authentication) and a different smtp server but now the networking guy said to use the new smtp server and authenticate.

What do you guys suggest to check or try? I've been out of programming for a few years now but I maintain this software for this company, I would like to try to test sending emails outside of my program with these settings to make sure the networking guy put the right credentials and setup the port correctly as well, can't remember how I used to do that! lol

Thank you!
 
STARTTLS points out the authentication method needs to be SSL/TLS, not plain text authentication.
As far as I know CDO only supports cdoNTLM = 2 as safest authentication type.

There are further configuration fields like sendtls and smtpusessl you might try to set them, too.

But you might not get CDO to work at all in an outlook 365 scenario, see:
So you very likely need a new way to send mails. Fortunately there are many ways.

Chriss
 
Thank you Chris,

What other way that works with VFP 9 do you recommend?

Thank you.
 
flpro,

it's not free but i have found Chilkat to be money well spent.

It will send via SMTP to office365 (but beware, each o365 account needs to be configured to allow SMTP).

If your users are using Outlook to send their emails then you can automate that. There's lots of example code scattered around for that.

Another alternative is to use the Office365 Rest API

An advantage of both outlook and RestAPI is that emails you send on their behalf will appear in their 'sent items' folder.

hth

n
 
Thank you so much guys,

Basically my application sends emails from different screens, I'm not concernced about showing it on outlook or each individual having it's own email account although it would be nice for them to see it on outlook, main concern is just sending emails and no history is required, my main concern would be to find the solution that is the easiest to implement now if the easiest one has the bells and whistles then great if not that's ok too, with examples etc. It's tough to get my mind back into programming mode when I'm doing something so different now but I can't leave my client, they need me, so trying to not spend to much time implementing this. I appreciate the feedback!

Thank you!
 
oh, also my FTP module is having some issues as well, so any recommendations for FTP integration into VFP 9 would be great as well.
 
VFPConnection FLL is mentioned in the Doug Hennig paper, it covers both mail and FTP - If you even just read the title of the white paper "Email and File Transfer the Fast (and Cheap!) Way" you alreaady knew it covers both.
West Wind Web Connections help is full of samples
The Chilkat Website I pointed to provides code to use their ActiveX, I mean the URL is example.code.com.

And the fox wiki entry also points to SMTP solutions which don't depend on a mail client available for MAPI use, but of course you would replace a SMPT mail solution with another one. Just one that is capable to make use of SSL/TLS encrypted authentication and sending, which Doug Hennig also mentions is usually needed.

Also on this forums FAQ section. you find an SMTP solutioon - which btw refers to the fox wiki entry for the latest version of the code: faq184-3840

So what are you waiting for? It's all there.
You don't trust my links? Then Google for
Chilkat VFP mail
Doug Henig mail FTP
Fox Wiki AutomatedEmail

Sorry for appearing to be indifferent to your question, but a multitde of solutions are out there and why should I replicate all samples given there here? Here it will outdate over time, there it can be updated (as used by the FAQ article providing a link to its latest version)

Sorry, I don't want to waste your time, you write and wait for an answer you already have. If you want a recommendation I vote for Chilkat or Web Connection.
Chilkat has very many things, they are actually C++ solutions provided in the form of OCXes but all VFP code samples for usage are there, you can cherrypick for each individual demand.
Web Connection covers all internet protocols and both Chilkat and Rick Strahl are very VFP oriented. CHilkat OCX may be reused in any other language supporting ActiveX.

And you have the necessary parameters for smtp server plus credentials.

Chriss
 
I can second (or whatever) the ChilKat approach, I have clients on Office365 for their mail and it runs well (TLS connected).

Of course if your client tries to do a clientless Office365, you do loose the whole automation thing, but it's currently still
easy to get local installs... and frankly there is very little in the way of improvement in the office products since (in my opinion)
about Office 2000 (maybe 95/97?)... so installing old versions just for that works quite well too!

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Hi flpro,

You may run into problems with FTP now or later because most providers no longer allow this insecure protocol.
Therefore I integrated WinSCP in my VFP webtool to be sure I can still upload to my websites. WinSCP is free and very user friendly once you have the right settings in place.

Regards, Gerrit

 
I like how many advice you got also from others. One more try: Did you test whether the additional CDO configuration options I mentioned earlier enable the secure connection against the odds of what was said in MS page about Office 365?

You're not automating Office when you address a mail server via SMTP.
To be clear you don't fail on Office365 automation your new situation needs a safe connection, the error happens in the connecting stage to the mail server, not to Office365.

And the mail server must also have moved or your code would continue to work. As Doug stated in his paper, it's more and more normal you can't send mails over a plaintext connection. And we're close to the leap that the newest TLS version becomes the necessary standard.

Chriss
 
Thank you so much guys,

Anyone else doing real estate? Totally different, I feel like a user now instead of a programmer! :p I'm leanig toward Chilkat but Dough Henning's seems interesting as well, a few questions:

1) Before I buy, is there a few things to check to make sure the problem is not on the network side and not my app?
2) One concern is compatability, as things change I don't want to be stuck with something that doesn't work anymore (like what is happening now), what would be the advantage of Dough Hennings vs Chilkat? I imagine Chilkat supports and updates their products actively? don't want to end up with a networking guy saying the problem is on the software side and I need to rewrite again.
3) All users are logging in to the cloud computer that has my app installed there, they run it from the cloud computer and as long as the app can send simple emails with attachments and able to send to CC as well then I'm good, any limitations with the number of users sending emails at the same time from the same computer?
4) For Chilkat, I need to download the "Chilkat 32 bit Active X MSI Installer" is that correct?
5) This Chilkat ActiveX contains both the email and FTP modules?

Thank you again!

Roy
 
1) Again asked:
myself said:
There are further configuration fields like sendtls and smtpusessl you might try to set them, too.
Have you tried that?

2) Nobody can guarantee endless compatibility and working. But if things change there will be new ways to send mail for sure, it's a pretty basic feature.
The way to send mails through an encrypted tunnel to a mail server is not new, the paradigm change is to enforce this. More and more servers don't accept plaintext connections.
Just like more and more sites on the web are https and not http anymore.

3) The number of user sessions is more a problem of resources needed in general than just by a mail function. You connect to another server - the mail server. You only upload the mail to it, the rest works from there. It's mostly an I/O bottleneck, if at all. Short mails? My god, how many short mails can you send through the bandwidth of a server. That isn't the problem.

4) I'd just ask them what you need. Also see
5) That is true for VFPConnection.FLL and VFPExMAPI.FLL - which Doug Hennig described. But it isn't from him, it's from Craig S. Boyd.
For the FLL functions see Doug Hennigs article. Title: "Email and File Transfer the Fast (and Cheap!) Way". The disadvantage is VFPExMAPI.FLL is using, well, MAPI, not SMTP.
Chilkat surely has both, but I guess that'll be 2 products. They offer 30-day trials.

Chriss
 
Chriss,

but I guess that'll be 2 products
Chilkat changed their licensing a few years ago...... the one purchase now buys the complete activeX bundle of components.

flpro,

FWIW my own decision tree would look like this.
Code:
DO CASE
CASE "customer uses desktop MSOutlook on same PC as my application"
[indent]automate outlook[/indent]
case "application sends emails unattended (perhaps as a scheduled task on a dedicated server/PC?)"
[indent]chilkat SMTP[/indent]
OTHERWISE
[indent]REST API[/indent]
ENDCASE

The disadvantage of SMTP with Office365 is that each o365 account needs to be configured to allow SMTP (which, in my world at least, requires a customer's 3rd party IT support to agree and configure.) But i appreciate in your specific case you may not want the bother of creating a RESTAPI class.
The disadvantage of REST API for unattended use is that it uses an oAuth token which can expire without a user to login again.

hth

n
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top