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!

Re: Mike Gagnon's FAQ... faq1251-4969 2

Status
Not open for further replies.

keepingbusy

Programmer
Apr 9, 2000
1,470
GB
Regarding Mike Gagnon's FAQ....
How to send e-mail using CDO and checking the connection status first
faq1251-4969

can anyone suggest how to accomplish the following:

I have used Mike's code (which obviously works) to send an email without using Outlook or Outlook express due to Outlook throwing up that "Someone is trying to send etc... and Outlook Express opening each time a automated email is created. Mike's process is very quick and efficient.

We have a table and wish to put the code in a loop to send emails to selected records within that table. MYTABLE contains a memo field where HTML code has been copied and pasted (It's a newsletter created in FrontPage).

When you use the code below, the email is sent but in the body of the received email, you see the HTML code.

Is there anyway to force the HTML code from the memo field into the SOURCE of the body of the email instead of it showing as code?

Here's what we use....
Code:
USE MYTABLE   && The memo field in the table is called [b]MAIN[/b]
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 address here'
    .Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25[/URL]
    .Update
  Endwith
  With iMsg
    .Configuration = iConf
    .To = "someone AT emailaddress DOT com"
    .CC = ""
    .BCC = ""
    .From = "someone AT emailaddress DOT com"
    .Subject = "This is a test"
    .TextBody = [b]MAIN[/b]
    .Send
  Endwith
  iMsg = .Null.
  iConf = .Null.
  wb = .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
Look forward to any replies

Lee....

Visual FoxPro Versions: 6 & 9
Operating System: Windows XP
 
Hi Lee,

According to intellisense .textbody is for plain text. Try substituting .HTMLBody.

Regards,

Mike
 
Hi Mike

Perfect!

As suggested, I changed the line as shown below and everything works fine.
Code:
.Subject = "This is a test"
[b].HTMLBody = MAIN[/b]
.Send
My sincerest thanks to you

Lee....

Visual FoxPro Versions: 6 & 9
Operating System: Windows XP
 
Hi Mike

Just hit a problem but not sure why. As you know, the code above worked fine but I've just tried to run it again this evening and the following error has appeared:

Code:
OLE Despatch exception code 0 from ?. The server rejected one or more recipient addresses. The server response was 550 must be authenticated
I am aware that my host requires emails to be authenticicated but why did it work in the first place? Maybe they got wind and blocked it I'm not sure.

You mentioned According to intellisense.... where can I find that and have you any idea (or anyone else) how I can get around this problem. I'm guessing that I need to add a line in the code somewhere

Many thanks
Lee

Visual FoxPro Versions: 6 & 9
Operating System: Windows XP
 
Lee

I am aware that my host requires emails to be authenticicated but why did it work in the first place? Maybe they got wind and blocked it I'm not sure.

Is the e-mail a valid e-mail address?



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Just an update on the last Mike, I've run a test this morning and it seems to be working again. The only explanation I can think of is that maybe there was a problem with the server.

If there's any change I'll post back.

Thank you for your time

Lee...

Visual FoxPro Versions: 6 & 9
Operating System: Windows XP
 

Just an update on the last Mike, I've run a test this morning and it seems to be working again. The only explanation I can think of is that maybe there was a problem with the server.

That would have been my next suggestion, to check the server logs to see if there was a problem.



Mike Gagnon

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

For your future reference. I typed:
iMsg = Createobject("CDO.Message")
imsg.
in the Command Window.
After typing the period, Intellisense popped up a list of available PEMs' with tooltips. This won't work in VFP6, but it should in VFP9.

Regards,

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top