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

CDO to send messages

Status
Not open for further replies.

ggrewe

IS-IT--Management
Jul 10, 2001
169
US
Hello,

I have an application running MS VFP 7.0 on a W2K server, trying to send e-mail through an Exchange 2000 (SP3) server that resides internally on another W2K server. I am trying to use CDO to send a simple SMTP message to a customer. This code works well to any internal address, but I cannot make it send a message outside. Originally I was getting a relay error, so I added the code to do smtp authentication. Now it will not work at all. ANy help is greatly appreciated.

LPARAMETERS lc_FileName, lc_FirstName, lc_LastName, lc_Email

LOCAL lc_Body, lo, lo_Item
LOCAL objMail, objConfig, objFields

lc_Body = 'Dear ' + ALLTRIM(lc_FirstName) + ' ' + ALLTRIM(lc_LastName) + ';' + CHR(13) + CHR(13) + ...

objMail = CreateObject("CDO.Message")
objConfig = CreateObject("CDO.Configuration")
objFields = objConfig.Fields

WITH objFields
.Item(" 2 &&& SMTP/POP Server
.Item(" "mailserver"
.Item(" 25
.Item(" = 10
.Item(" = 1
.Item(" = "id"
.Item(" = "password"
.Update
ENDWITH

WITH objMail
.Configuration = objConfig
.From = "sales@gorb.net"
.To = lc_email
.Subject = "Home Comfort System Proposal from Recker and Boerger"
.TextBody = lc_Body
.AddAttachment(lc_FileName + ".PDF")
.Send
ENDWITH

RELEASE objMail, objConfig, objFields

RETURN
 
ggrewe

You may find some help with faq184-1769.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike;

Thanks for your help, but after reading this FAQ, it appears that the recipient has to be in the address book. I need to send an e-mail to an outside internet address. Can you tell me the syntax for for that? I have tried ".To" and it does not work with this configuration. Thanks.
 
ggrewe

About this?

Code:
oMSG = CREATEOBJECT("cdo.message")
oMSG.To = "me@hotmail.com"
oMSG.From = "me"
oMSG.Subject = "Hello Email"
oMSG.TextBody = "This is an easy way to create an email"
oMSG.Send()


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike;

This takes me back to where I started. When I use this process, the Exchange server thinks I am trying to relay mail. If I use the method in your FAQ, then I have to use an address in the address book. Both methods work when the message stays in house, but the problem happens when I try to send the message outside, to an internet address.
 
ggrewe

It would seem that your are trying to use Exchange, but not really. Why use the Exchange route if you do not plan to use its address book? How about just automating Outlook instead?

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike;

I was Automating Outlook, but the security prompt keeps coming up. I was trying to find a way around that, and CDO seems to work well, expect for when I send mail outside. I do not need to use the Exchange piece, but when I try sending the mail with "Sendusing"=2 (SMTP), then the Exchange server bounces the mail back as being relayed. I have tried various different configurations and I cannot seem to find a solution that works. The code at the beginning of this post works great against my mail server, but I cannot seem to make it work with the clients Exchange server. DO you have any ideas?
 

How about faq184-1856?

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
One option is to enable the SMTP service on the local W2K server and only allow it to receive connections from 127.0.0.1 (the local machine). This will get around the problem.

You can then use 127.0.0.1 as the SMTP server in the code above.

Cheers,

Andrew

Andrew Coates
OzFox 2003 Australia's VFP Conference -- ------
DISCLOSURE
We are the Australasian Distributor for the Hentzenwerke Series of Books. (By the same token, I really do think they're the best printed VFP resource out there -- that's why we sell them)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top