Web Connection
SMTP - impomplete session error
Gravatar is a globally recognized avatar based on your email address. SMTP - impomplete session error
  Harvey Mushman
  All
  Sep 17, 2014 @ 03:50pm
OK, the my error still seems to exist when trying to send using the following code. The first address from my mailing list table goes without any problems be 2-n all show Incomplete-Session in the server logs.

A bit about my environment... My mail server is on the same LAN as my routine below which is running from my laptop.

Here is my code (excluding SMTP setup):

DO wwSmtp
LOCAL loSmtp as wwSmtp

*** setup smtp properties goes here along with opening table ***


SELECT('myList')
loSmtp.Connect()
SCAN

* prevent from sending twice
IF NOT EMPTY(result)
LOOP
ENDIF

loSmtp.cRecipient = ["] +ALLTRIM(STRTRAN(sender,',',' ')) + '" <' + ALLTRIM(email) +'>'
*loSmtp.cReplyTo = ALLTRIM(AcntName)
*** Now Sending ***

llResult = loSmtp.SendMessage()
* WAIT TIMEOUT .25
IF llResult
REPLACE Result WITH TRANSFORM(DATETIME())
ELSE
REPLACE Result WITH LEFT( loSmtp.cErrorMsg, 100)
ENDIF

ENDSCAN
loSmtp.Close()

I've left out all of the setup code for SMPT but basically copied and pasted in the sample code from the SendMessage documentation. And since the first message gets delivered correctly the problem is not in the configuration of SMTP.

Any help would be most welcome...

--hm--

Gravatar is a globally recognized avatar based on your email address. Re: SMTP - impomplete session error
  Harvey Mushman
  Harvey Mushman
  Sep 18, 2014 @ 05:20am
FYI - in testing if I move the loSmtp.Connect and loSmtp.Dispose into the SCAN loop (with connect at the top and dispose at the end), the server accepts and sends all of the messages without error.

--hm


OK, the my error still seems to exist when trying to send using the following code. The first address from my mailing list table goes without any problems be 2-n all show Incomplete-Session in the server logs.

A bit about my environment... My mail server is on the same LAN as my routine below which is running from my laptop.

Here is my code (excluding SMTP setup):

DO wwSmtp
LOCAL loSmtp as wwSmtp

*** setup smtp properties goes here along with opening table ***


SELECT('myList')
loSmtp.Connect()
SCAN

* prevent from sending twice
IF NOT EMPTY(result)
LOOP
ENDIF

loSmtp.cRecipient = ["] +ALLTRIM(STRTRAN(sender,',',' ')) + '" <' + ALLTRIM(email) +'>'
*loSmtp.cReplyTo = ALLTRIM(AcntName)
*** Now Sending ***

llResult = loSmtp.SendMessage()
* WAIT TIMEOUT .25
IF llResult
REPLACE Result WITH TRANSFORM(DATETIME())
ELSE
REPLACE Result WITH LEFT( loSmtp.cErrorMsg, 100)
ENDIF

ENDSCAN
loSmtp.Close()

I've left out all of the setup code for SMPT but basically copied and pasted in the sample code from the SendMessage documentation. And since the first message gets delivered correctly the problem is not in the configuration of SMTP.

Any help would be most welcome...


--hm--

Gravatar is a globally recognized avatar based on your email address. Re: SMTP - impomplete session error
  Harvey Mushman
  Harvey Mushman
  Sep 18, 2014 @ 07:09am
PS - discovered the AddAttachment() must exist within the Connect - Dispose. Although this was the only property of the object that seemed to have not worked when I moved the Connect and Dispose to inside the SCAN loop.

Is this by design or could it be related to the cause of the problem...?

--hm


FYI - in testing if I move the loSmtp.Connect and loSmtp.Dispose into the SCAN loop (with connect at the top and dispose at the end), the server accepts and sends all of the messages without error.

--hm


OK, the my error still seems to exist when trying to send using the following code. The first address from my mailing list table goes without any problems be 2-n all show Incomplete-Session in the server logs.

A bit about my environment... My mail server is on the same LAN as my routine below which is running from my laptop.

Here is my code (excluding SMTP setup):

DO wwSmtp
LOCAL loSmtp as wwSmtp

*** setup smtp properties goes here along with opening table ***


SELECT('myList')
loSmtp.Connect()
SCAN

* prevent from sending twice
IF NOT EMPTY(result)
LOOP
ENDIF

loSmtp.cRecipient = ["] +ALLTRIM(STRTRAN(sender,',',' ')) + '" <' + ALLTRIM(email) +'>'
*loSmtp.cReplyTo = ALLTRIM(AcntName)
*** Now Sending ***

llResult = loSmtp.SendMessage()
* WAIT TIMEOUT .25
IF llResult
REPLACE Result WITH TRANSFORM(DATETIME())
ELSE
REPLACE Result WITH LEFT( loSmtp.cErrorMsg, 100)
ENDIF

ENDSCAN
loSmtp.Close()

I've left out all of the setup code for SMPT but basically copied and pasted in the sample code from the SendMessage documentation. And since the first message gets delivered correctly the problem is not in the configuration of SMTP.

Any help would be most welcome...



--hm--

Gravatar is a globally recognized avatar based on your email address. Re: SMTP - impomplete session error
  Rick Strahl
  Harvey Mushman
  Sep 18, 2014 @ 11:10am
Jim,

I just double checked this on my machine.

Can you setup the wwSmtp_sample.prg in the wwIpstuff_samples folder by just modifying for your mail server setup? One of the options in that file (commented out by default) is to make two SendMessage calls in a row. I ran that code and I got two email messages. Please check with that code... I used GMail for testing as well as my ISP here in Hood River and it worked with both. Maybe if it doesn't work try using a GMail or other public account to see if that gives different results.

If that doesn't work I'm not sure. It could be some mail server compatibility issue...

+++ Rick ---



OK, the my error still seems to exist when trying to send using the following code. The first address from my mailing list table goes without any problems be 2-n all show Incomplete-Session in the server logs.

A bit about my environment... My mail server is on the same LAN as my routine below which is running from my laptop.

Here is my code (excluding SMTP setup):

DO wwSmtp
LOCAL loSmtp as wwSmtp

*** setup smtp properties goes here along with opening table ***


SELECT('myList')
loSmtp.Connect()
SCAN

* prevent from sending twice
IF NOT EMPTY(result)
LOOP
ENDIF

loSmtp.cRecipient = ["] +ALLTRIM(STRTRAN(sender,',',' ')) + '" <' + ALLTRIM(email) +'>'
*loSmtp.cReplyTo = ALLTRIM(AcntName)
*** Now Sending ***

llResult = loSmtp.SendMessage()
* WAIT TIMEOUT .25
IF llResult
REPLACE Result WITH TRANSFORM(DATETIME())
ELSE
REPLACE Result WITH LEFT( loSmtp.cErrorMsg, 100)
ENDIF

ENDSCAN
loSmtp.Close()

I've left out all of the setup code for SMPT but basically copied and pasted in the sample code from the SendMessage documentation. And since the first message gets delivered correctly the problem is not in the configuration of SMTP.

Any help would be most welcome...



Rick Strahl
West Wind Technologies

Making waves on the Web
from Maui

Gravatar is a globally recognized avatar based on your email address. Re: SMTP - impomplete session error
  Rick Strahl
  Harvey Mushman
  Sep 18, 2014 @ 12:18pm
Well, then just use SendMail() which is easier. SendMessage() is meant to send multiple messages from a single connection which is faster... if speed isn't important using SendMail() is fine... since apparently there's some sort of conflict between client and server for multiple sends on the same connection.

+++ Rick ---



FYI - in testing if I move the loSmtp.Connect and loSmtp.Dispose into the SCAN loop (with connect at the top and dispose at the end), the server accepts and sends all of the messages without error.

--hm


OK, the my error still seems to exist when trying to send using the following code. The first address from my mailing list table goes without any problems be 2-n all show Incomplete-Session in the server logs.

A bit about my environment... My mail server is on the same LAN as my routine below which is running from my laptop.

Here is my code (excluding SMTP setup):

DO wwSmtp
LOCAL loSmtp as wwSmtp

*** setup smtp properties goes here along with opening table ***


SELECT('myList')
loSmtp.Connect()
SCAN

* prevent from sending twice
IF NOT EMPTY(result)
LOOP
ENDIF

loSmtp.cRecipient = ["] +ALLTRIM(STRTRAN(sender,',',' ')) + '" <' + ALLTRIM(email) +'>'
*loSmtp.cReplyTo = ALLTRIM(AcntName)
*** Now Sending ***

llResult = loSmtp.SendMessage()
* WAIT TIMEOUT .25
IF llResult
REPLACE Result WITH TRANSFORM(DATETIME())
ELSE
REPLACE Result WITH LEFT( loSmtp.cErrorMsg, 100)
ENDIF

ENDSCAN
loSmtp.Close()

I've left out all of the setup code for SMPT but basically copied and pasted in the sample code from the SendMessage documentation. And since the first message gets delivered correctly the problem is not in the configuration of SMTP.

Any help would be most welcome...




Rick Strahl
West Wind Technologies

Making waves on the Web
from Maui

Gravatar is a globally recognized avatar based on your email address. Re: SMTP - impomplete session error
  Harvey Mushman
  Rick Strahl
  Sep 18, 2014 @ 01:51pm
Thanks for both your posts. We have an event tonight that I'm working to get ready for but will give you feedback over the weekend. Thanks for double checking.

--hm


Well, then just use SendMail() which is easier. SendMessage() is meant to send multiple messages from a single connection which is faster... if speed isn't important using SendMail() is fine... since apparently there's some sort of conflict between client and server for multiple sends on the same connection.

+++ Rick ---



FYI - in testing if I move the loSmtp.Connect and loSmtp.Dispose into the SCAN loop (with connect at the top and dispose at the end), the server accepts and sends all of the messages without error.

--hm


OK, the my error still seems to exist when trying to send using the following code. The first address from my mailing list table goes without any problems be 2-n all show Incomplete-Session in the server logs.

A bit about my environment... My mail server is on the same LAN as my routine below which is running from my laptop.

Here is my code (excluding SMTP setup):

DO wwSmtp
LOCAL loSmtp as wwSmtp

*** setup smtp properties goes here along with opening table ***


SELECT('myList')
loSmtp.Connect()
SCAN

* prevent from sending twice
IF NOT EMPTY(result)
LOOP
ENDIF

loSmtp.cRecipient = ["] +ALLTRIM(STRTRAN(sender,',',' ')) + '" <' + ALLTRIM(email) +'>'
*loSmtp.cReplyTo = ALLTRIM(AcntName)
*** Now Sending ***

llResult = loSmtp.SendMessage()
* WAIT TIMEOUT .25
IF llResult
REPLACE Result WITH TRANSFORM(DATETIME())
ELSE
REPLACE Result WITH LEFT( loSmtp.cErrorMsg, 100)
ENDIF

ENDSCAN
loSmtp.Close()

I've left out all of the setup code for SMPT but basically copied and pasted in the sample code from the SendMessage documentation. And since the first message gets delivered correctly the problem is not in the configuration of SMTP.

Any help would be most welcome...





--hm--

Gravatar is a globally recognized avatar based on your email address. Re: SMTP - impomplete session error
  Harvey Mushman
  Rick Strahl
  Oct 18, 2014 @ 01:05pm
Discovered what was causing my problem although not sure why it does not work?

My setup code was the issue...

DO wwSmtp
LOCAL loSmtp as wwSmtp
loSmtp = CREATEOBJECT("wwSmtp")

* loSmtp.nMailMode = 0 && .NET 2 - classic (default)

By commenting out the nMailMode = 0 which I understood used the .NET version of WC, o.SendMessage looping inside the o.Connect to o.Close now works fine.

Who knew... :-)

--hm



Jim,

I just double checked this on my machine.

Can you setup the wwSmtp_sample.prg in the wwIpstuff_samples folder by just modifying for your mail server setup? One of the options in that file (commented out by default) is to make two SendMessage calls in a row. I ran that code and I got two email messages. Please check with that code... I used GMail for testing as well as my ISP here in Hood River and it worked with both. Maybe if it doesn't work try using a GMail or other public account to see if that gives different results.

If that doesn't work I'm not sure. It could be some mail server compatibility issue...

+++ Rick ---



OK, the my error still seems to exist when trying to send using the following code. The first address from my mailing list table goes without any problems be 2-n all show Incomplete-Session in the server logs.

A bit about my environment... My mail server is on the same LAN as my routine below which is running from my laptop.

Here is my code (excluding SMTP setup):

DO wwSmtp
LOCAL loSmtp as wwSmtp

*** setup smtp properties goes here along with opening table ***


SELECT('myList')
loSmtp.Connect()
SCAN

* prevent from sending twice
IF NOT EMPTY(result)
LOOP
ENDIF

loSmtp.cRecipient = ["] +ALLTRIM(STRTRAN(sender,',',' ')) + '" <' + ALLTRIM(email) +'>'
*loSmtp.cReplyTo = ALLTRIM(AcntName)
*** Now Sending ***

llResult = loSmtp.SendMessage()
* WAIT TIMEOUT .25
IF llResult
REPLACE Result WITH TRANSFORM(DATETIME())
ELSE
REPLACE Result WITH LEFT( loSmtp.cErrorMsg, 100)
ENDIF

ENDSCAN
loSmtp.Close()

I've left out all of the setup code for SMPT but basically copied and pasted in the sample code from the SendMessage documentation. And since the first message gets delivered correctly the problem is not in the configuration of SMTP.

Any help would be most welcome...




--hm--

Gravatar is a globally recognized avatar based on your email address. Re: SMTP - impomplete session error
  Rick Strahl
  Harvey Mushman
  Oct 20, 2014 @ 12:49pm

The default mode doesn't use .NET so you're going through a completely different pipeline to send emails.

If the .NET code doesn't work check for errors. Most likely you don't have .NET installed on your server.

+++ Rick ---



Discovered what was causing my problem although not sure why it does not work?

My setup code was the issue...

DO wwSmtp
LOCAL loSmtp as wwSmtp
loSmtp = CREATEOBJECT("wwSmtp")

* loSmtp.nMailMode = 0 && .NET 2 - classic (default)

By commenting out the nMailMode = 0 which I understood used the .NET version of WC, o.SendMessage looping inside the o.Connect to o.Close now works fine.

Who knew... :-)

--hm



Jim,

I just double checked this on my machine.

Can you setup the wwSmtp_sample.prg in the wwIpstuff_samples folder by just modifying for your mail server setup? One of the options in that file (commented out by default) is to make two SendMessage calls in a row. I ran that code and I got two email messages. Please check with that code... I used GMail for testing as well as my ISP here in Hood River and it worked with both. Maybe if it doesn't work try using a GMail or other public account to see if that gives different results.

If that doesn't work I'm not sure. It could be some mail server compatibility issue...

+++ Rick ---



OK, the my error still seems to exist when trying to send using the following code. The first address from my mailing list table goes without any problems be 2-n all show Incomplete-Session in the server logs.

A bit about my environment... My mail server is on the same LAN as my routine below which is running from my laptop.

Here is my code (excluding SMTP setup):

DO wwSmtp
LOCAL loSmtp as wwSmtp

*** setup smtp properties goes here along with opening table ***


SELECT('myList')
loSmtp.Connect()
SCAN

* prevent from sending twice
IF NOT EMPTY(result)
LOOP
ENDIF

loSmtp.cRecipient = ["] +ALLTRIM(STRTRAN(sender,',',' ')) + '" <' + ALLTRIM(email) +'>'
*loSmtp.cReplyTo = ALLTRIM(AcntName)
*** Now Sending ***

llResult = loSmtp.SendMessage()
* WAIT TIMEOUT .25
IF llResult
REPLACE Result WITH TRANSFORM(DATETIME())
ELSE
REPLACE Result WITH LEFT( loSmtp.cErrorMsg, 100)
ENDIF

ENDSCAN
loSmtp.Close()

I've left out all of the setup code for SMPT but basically copied and pasted in the sample code from the SendMessage documentation. And since the first message gets delivered correctly the problem is not in the configuration of SMTP.

Any help would be most welcome...






Rick Strahl
West Wind Technologies

Making waves on the Web
from Maui

Gravatar is a globally recognized avatar based on your email address. Re: SMTP - impomplete session error
  Harvey Mushman
  Rick Strahl
  Oct 20, 2014 @ 03:57pm
I'm running the VFP routing on my laptop. I would think all the code is executing on it and the only server in this case would be my mail server. In this case my version of Dot NET is 4.5. I will send you a screen shot offline.

Because your reply threw me a curve with the word "server" having dot net, I also looked at the system which the mail server sits on. Mind you this machine is strictly used for mail which is not Exchange so the need for dot NET has never come up before. It is running version 1.1 which I assume was installed at the time the machine was configured.

--hm


The default mode doesn't use .NET so you're going through a completely different pipeline to send emails.

If the .NET code doesn't work check for errors. Most likely you don't have .NET installed on your server.

+++ Rick ---



Discovered what was causing my problem although not sure why it does not work?

My setup code was the issue...

DO wwSmtp
LOCAL loSmtp as wwSmtp
loSmtp = CREATEOBJECT("wwSmtp")

* loSmtp.nMailMode = 0 && .NET 2 - classic (default)

By commenting out the nMailMode = 0 which I understood used the .NET version of WC, o.SendMessage looping inside the o.Connect to o.Close now works fine.

Who knew... :-)

--hm



Jim,

I just double checked this on my machine.

Can you setup the wwSmtp_sample.prg in the wwIpstuff_samples folder by just modifying for your mail server setup? One of the options in that file (commented out by default) is to make two SendMessage calls in a row. I ran that code and I got two email messages. Please check with that code... I used GMail for testing as well as my ISP here in Hood River and it worked with both. Maybe if it doesn't work try using a GMail or other public account to see if that gives different results.

If that doesn't work I'm not sure. It could be some mail server compatibility issue...

+++ Rick ---



OK, the my error still seems to exist when trying to send using the following code. The first address from my mailing list table goes without any problems be 2-n all show Incomplete-Session in the server logs.

A bit about my environment... My mail server is on the same LAN as my routine below which is running from my laptop.

Here is my code (excluding SMTP setup):

DO wwSmtp
LOCAL loSmtp as wwSmtp

*** setup smtp properties goes here along with opening table ***


SELECT('myList')
loSmtp.Connect()
SCAN

* prevent from sending twice
IF NOT EMPTY(result)
LOOP
ENDIF

loSmtp.cRecipient = ["] +ALLTRIM(STRTRAN(sender,',',' ')) + '" <' + ALLTRIM(email) +'>'
*loSmtp.cReplyTo = ALLTRIM(AcntName)
*** Now Sending ***

llResult = loSmtp.SendMessage()
* WAIT TIMEOUT .25
IF llResult
REPLACE Result WITH TRANSFORM(DATETIME())
ELSE
REPLACE Result WITH LEFT( loSmtp.cErrorMsg, 100)
ENDIF

ENDSCAN
loSmtp.Close()

I've left out all of the setup code for SMPT but basically copied and pasted in the sample code from the SendMessage documentation. And since the first message gets delivered correctly the problem is not in the configuration of SMTP.

Any help would be most welcome...







--hm--

Gravatar is a globally recognized avatar based on your email address. Re: SMTP - impomplete session error
  Rick Strahl
  Harvey Mushman
  Oct 20, 2014 @ 11:02pm

You only need .NET from wherever you are sending the email not on the server - I just assumed you were doing this on your server FoxPro application.

+++ Rick ---



I'm running the VFP routing on my laptop. I would think all the code is executing on it and the only server in this case would be my mail server. In this case my version of Dot NET is 4.5. I will send you a screen shot offline.

Because your reply threw me a curve with the word "server" having dot net, I also looked at the system which the mail server sits on. Mind you this machine is strictly used for mail which is not Exchange so the need for dot NET has never come up before. It is running version 1.1 which I assume was installed at the time the machine was configured.

--hm


The default mode doesn't use .NET so you're going through a completely different pipeline to send emails.

If the .NET code doesn't work check for errors. Most likely you don't have .NET installed on your server.

+++ Rick ---



Discovered what was causing my problem although not sure why it does not work?

My setup code was the issue...

DO wwSmtp
LOCAL loSmtp as wwSmtp
loSmtp = CREATEOBJECT("wwSmtp")

* loSmtp.nMailMode = 0 && .NET 2 - classic (default)

By commenting out the nMailMode = 0 which I understood used the .NET version of WC, o.SendMessage looping inside the o.Connect to o.Close now works fine.

Who knew... :-)

--hm



Jim,

I just double checked this on my machine.

Can you setup the wwSmtp_sample.prg in the wwIpstuff_samples folder by just modifying for your mail server setup? One of the options in that file (commented out by default) is to make two SendMessage calls in a row. I ran that code and I got two email messages. Please check with that code... I used GMail for testing as well as my ISP here in Hood River and it worked with both. Maybe if it doesn't work try using a GMail or other public account to see if that gives different results.

If that doesn't work I'm not sure. It could be some mail server compatibility issue...

+++ Rick ---



OK, the my error still seems to exist when trying to send using the following code. The first address from my mailing list table goes without any problems be 2-n all show Incomplete-Session in the server logs.

A bit about my environment... My mail server is on the same LAN as my routine below which is running from my laptop.

Here is my code (excluding SMTP setup):

DO wwSmtp
LOCAL loSmtp as wwSmtp

*** setup smtp properties goes here along with opening table ***


SELECT('myList')
loSmtp.Connect()
SCAN

* prevent from sending twice
IF NOT EMPTY(result)
LOOP
ENDIF

loSmtp.cRecipient = ["] +ALLTRIM(STRTRAN(sender,',',' ')) + '" <' + ALLTRIM(email) +'>'
*loSmtp.cReplyTo = ALLTRIM(AcntName)
*** Now Sending ***

llResult = loSmtp.SendMessage()
* WAIT TIMEOUT .25
IF llResult
REPLACE Result WITH TRANSFORM(DATETIME())
ELSE
REPLACE Result WITH LEFT( loSmtp.cErrorMsg, 100)
ENDIF

ENDSCAN
loSmtp.Close()

I've left out all of the setup code for SMPT but basically copied and pasted in the sample code from the SendMessage documentation. And since the first message gets delivered correctly the problem is not in the configuration of SMTP.

Any help would be most welcome...









Rick Strahl
West Wind Technologies

Making waves on the Web
from Maui

Gravatar is a globally recognized avatar based on your email address. Re: SMTP - impomplete session error
  Harvey Mushman
  Rick Strahl
  Oct 21, 2014 @ 06:49am
Then the error is real and you need to take another look!

Reminder....

SendMessage() where the loSmtp.Connect() is before the SCAN loop of email addresses to send and where the loSmtp.Close() is after the ENDSCAN.

If I Connect() and Close() within the scan loop using the dotNET provider, then it works fine. But not as your documentation suggests where connection is held open for the duration of the loop.

This error is reproducible by copying your code from the online documentation and only changing this one parameter

loSmtp.nMailMode = 0

If you don't have this problem, I will be very surprised!

Thank you in advance for taking the time to look again.

--hm

You only need .NET from wherever you are sending the email not on the server - I just assumed you were doing this on your server FoxPro application.

+++ Rick ---



I'm running the VFP routing on my laptop. I would think all the code is executing on it and the only server in this case would be my mail server. In this case my version of Dot NET is 4.5. I will send you a screen shot offline.

Because your reply threw me a curve with the word "server" having dot net, I also looked at the system which the mail server sits on. Mind you this machine is strictly used for mail which is not Exchange so the need for dot NET has never come up before. It is running version 1.1 which I assume was installed at the time the machine was configured.

--hm


The default mode doesn't use .NET so you're going through a completely different pipeline to send emails.

If the .NET code doesn't work check for errors. Most likely you don't have .NET installed on your server.

+++ Rick ---



Discovered what was causing my problem although not sure why it does not work?

My setup code was the issue...

DO wwSmtp
LOCAL loSmtp as wwSmtp
loSmtp = CREATEOBJECT("wwSmtp")

* loSmtp.nMailMode = 0 && .NET 2 - classic (default)

By commenting out the nMailMode = 0 which I understood used the .NET version of WC, o.SendMessage looping inside the o.Connect to o.Close now works fine.

Who knew... :-)

--hm



Jim,

I just double checked this on my machine.

Can you setup the wwSmtp_sample.prg in the wwIpstuff_samples folder by just modifying for your mail server setup? One of the options in that file (commented out by default) is to make two SendMessage calls in a row. I ran that code and I got two email messages. Please check with that code... I used GMail for testing as well as my ISP here in Hood River and it worked with both. Maybe if it doesn't work try using a GMail or other public account to see if that gives different results.

If that doesn't work I'm not sure. It could be some mail server compatibility issue...

+++ Rick ---



OK, the my error still seems to exist when trying to send using the following code. The first address from my mailing list table goes without any problems be 2-n all show Incomplete-Session in the server logs.

A bit about my environment... My mail server is on the same LAN as my routine below which is running from my laptop.

Here is my code (excluding SMTP setup):

DO wwSmtp
LOCAL loSmtp as wwSmtp

*** setup smtp properties goes here along with opening table ***


SELECT('myList')
loSmtp.Connect()
SCAN

* prevent from sending twice
IF NOT EMPTY(result)
LOOP
ENDIF

loSmtp.cRecipient = ["] +ALLTRIM(STRTRAN(sender,',',' ')) + '" <' + ALLTRIM(email) +'>'
*loSmtp.cReplyTo = ALLTRIM(AcntName)
*** Now Sending ***

llResult = loSmtp.SendMessage()
* WAIT TIMEOUT .25
IF llResult
REPLACE Result WITH TRANSFORM(DATETIME())
ELSE
REPLACE Result WITH LEFT( loSmtp.cErrorMsg, 100)
ENDIF

ENDSCAN
loSmtp.Close()

I've left out all of the setup code for SMPT but basically copied and pasted in the sample code from the SendMessage documentation. And since the first message gets delivered correctly the problem is not in the configuration of SMTP.

Any help would be most welcome...










--hm--

Gravatar is a globally recognized avatar based on your email address. Re: SMTP - impomplete session error
  Rick Strahl
  Harvey Mushman
  Oct 21, 2014 @ 04:55pm

I'm not sure what you're saying. in MailMode 0 you can just send messages and leave the connection open. That only works in .NET. The classic version will always open and close connections for everything.

+++ Rick ---



Then the error is real and you need to take another look!

Reminder....

SendMessage() where the loSmtp.Connect() is before the SCAN loop of email addresses to send and where the loSmtp.Close() is after the ENDSCAN.

If I Connect() and Close() within the scan loop using the dotNET provider, then it works fine. But not as your documentation suggests where connection is held open for the duration of the loop.

This error is reproducible by copying your code from the online documentation and only changing this one parameter

loSmtp.nMailMode = 0

If you don't have this problem, I will be very surprised!

Thank you in advance for taking the time to look again.

--hm

You only need .NET from wherever you are sending the email not on the server - I just assumed you were doing this on your server FoxPro application.

+++ Rick ---



I'm running the VFP routing on my laptop. I would think all the code is executing on it and the only server in this case would be my mail server. In this case my version of Dot NET is 4.5. I will send you a screen shot offline.

Because your reply threw me a curve with the word "server" having dot net, I also looked at the system which the mail server sits on. Mind you this machine is strictly used for mail which is not Exchange so the need for dot NET has never come up before. It is running version 1.1 which I assume was installed at the time the machine was configured.

--hm


The default mode doesn't use .NET so you're going through a completely different pipeline to send emails.

If the .NET code doesn't work check for errors. Most likely you don't have .NET installed on your server.

+++ Rick ---



Discovered what was causing my problem although not sure why it does not work?

My setup code was the issue...

DO wwSmtp
LOCAL loSmtp as wwSmtp
loSmtp = CREATEOBJECT("wwSmtp")

* loSmtp.nMailMode = 0 && .NET 2 - classic (default)

By commenting out the nMailMode = 0 which I understood used the .NET version of WC, o.SendMessage looping inside the o.Connect to o.Close now works fine.

Who knew... :-)

--hm



Jim,

I just double checked this on my machine.

Can you setup the wwSmtp_sample.prg in the wwIpstuff_samples folder by just modifying for your mail server setup? One of the options in that file (commented out by default) is to make two SendMessage calls in a row. I ran that code and I got two email messages. Please check with that code... I used GMail for testing as well as my ISP here in Hood River and it worked with both. Maybe if it doesn't work try using a GMail or other public account to see if that gives different results.

If that doesn't work I'm not sure. It could be some mail server compatibility issue...

+++ Rick ---



OK, the my error still seems to exist when trying to send using the following code. The first address from my mailing list table goes without any problems be 2-n all show Incomplete-Session in the server logs.

A bit about my environment... My mail server is on the same LAN as my routine below which is running from my laptop.

Here is my code (excluding SMTP setup):

DO wwSmtp
LOCAL loSmtp as wwSmtp

*** setup smtp properties goes here along with opening table ***


SELECT('myList')
loSmtp.Connect()
SCAN

* prevent from sending twice
IF NOT EMPTY(result)
LOOP
ENDIF

loSmtp.cRecipient = ["] +ALLTRIM(STRTRAN(sender,',',' ')) + '" <' + ALLTRIM(email) +'>'
*loSmtp.cReplyTo = ALLTRIM(AcntName)
*** Now Sending ***

llResult = loSmtp.SendMessage()
* WAIT TIMEOUT .25
IF llResult
REPLACE Result WITH TRANSFORM(DATETIME())
ELSE
REPLACE Result WITH LEFT( loSmtp.cErrorMsg, 100)
ENDIF

ENDSCAN
loSmtp.Close()

I've left out all of the setup code for SMPT but basically copied and pasted in the sample code from the SendMessage documentation. And since the first message gets delivered correctly the problem is not in the configuration of SMTP.

Any help would be most welcome...












Rick Strahl
West Wind Technologies

Making waves on the Web
from Maui

Gravatar is a globally recognized avatar based on your email address. Re: SMTP - impomplete session error
  Harvey Mushman
  Rick Strahl
  Oct 22, 2014 @ 08:38am
When I copy and paste your example from the online documentation, the code works just fine.

Hum... something stinks like rotten fish!! <frown>

Then after another hour plus of comparing my code to your sample, I discovered one slight difference.

loSmtp.AddAttachment("C:\myFolder\myAcrobatFile.pdf","pdf/application")

VS.

loSmtp.cAttachment = "C:\myFolder\myAcrobatFile.pdf"

What I've discovered is cAttachment works in both classic nMailMode and in dot NET. On the other hand, AddAttachment only works on the first message inside the loop when dot NET nMailMode is selected.

Bug or Feature?

....James@Cranky.com! <g>

--hm

I'm not sure what you're saying. in MailMode 0 you can just send messages and leave the connection open. That only works in .NET. The classic version will always open and close connections for everything.

+++ Rick ---



Then the error is real and you need to take another look!

Reminder....

SendMessage() where the loSmtp.Connect() is before the SCAN loop of email addresses to send and where the loSmtp.Close() is after the ENDSCAN.

If I Connect() and Close() within the scan loop using the dotNET provider, then it works fine. But not as your documentation suggests where connection is held open for the duration of the loop.

This error is reproducible by copying your code from the online documentation and only changing this one parameter

loSmtp.nMailMode = 0

If you don't have this problem, I will be very surprised!

Thank you in advance for taking the time to look again.

--hm

You only need .NET from wherever you are sending the email not on the server - I just assumed you were doing this on your server FoxPro application.

+++ Rick ---



I'm running the VFP routing on my laptop. I would think all the code is executing on it and the only server in this case would be my mail server. In this case my version of Dot NET is 4.5. I will send you a screen shot offline.

Because your reply threw me a curve with the word "server" having dot net, I also looked at the system which the mail server sits on. Mind you this machine is strictly used for mail which is not Exchange so the need for dot NET has never come up before. It is running version 1.1 which I assume was installed at the time the machine was configured.

--hm


The default mode doesn't use .NET so you're going through a completely different pipeline to send emails.

If the .NET code doesn't work check for errors. Most likely you don't have .NET installed on your server.

+++ Rick ---



Discovered what was causing my problem although not sure why it does not work?

My setup code was the issue...

DO wwSmtp
LOCAL loSmtp as wwSmtp
loSmtp = CREATEOBJECT("wwSmtp")

* loSmtp.nMailMode = 0 && .NET 2 - classic (default)

By commenting out the nMailMode = 0 which I understood used the .NET version of WC, o.SendMessage looping inside the o.Connect to o.Close now works fine.

Who knew... :-)

--hm



Jim,

I just double checked this on my machine.

Can you setup the wwSmtp_sample.prg in the wwIpstuff_samples folder by just modifying for your mail server setup? One of the options in that file (commented out by default) is to make two SendMessage calls in a row. I ran that code and I got two email messages. Please check with that code... I used GMail for testing as well as my ISP here in Hood River and it worked with both. Maybe if it doesn't work try using a GMail or other public account to see if that gives different results.

If that doesn't work I'm not sure. It could be some mail server compatibility issue...

+++ Rick ---



OK, the my error still seems to exist when trying to send using the following code. The first address from my mailing list table goes without any problems be 2-n all show Incomplete-Session in the server logs.

A bit about my environment... My mail server is on the same LAN as my routine below which is running from my laptop.

Here is my code (excluding SMTP setup):

DO wwSmtp
LOCAL loSmtp as wwSmtp

*** setup smtp properties goes here along with opening table ***


SELECT('myList')
loSmtp.Connect()
SCAN

* prevent from sending twice
IF NOT EMPTY(result)
LOOP
ENDIF

loSmtp.cRecipient = ["] +ALLTRIM(STRTRAN(sender,',',' ')) + '" <' + ALLTRIM(email) +'>'
*loSmtp.cReplyTo = ALLTRIM(AcntName)
*** Now Sending ***

llResult = loSmtp.SendMessage()
* WAIT TIMEOUT .25
IF llResult
REPLACE Result WITH TRANSFORM(DATETIME())
ELSE
REPLACE Result WITH LEFT( loSmtp.cErrorMsg, 100)
ENDIF

ENDSCAN
loSmtp.Close()

I've left out all of the setup code for SMPT but basically copied and pasted in the sample code from the SendMessage documentation. And since the first message gets delivered correctly the problem is not in the configuration of SMTP.

Any help would be most welcome...













--hm--

Gravatar is a globally recognized avatar based on your email address. Re: SMTP - impomplete session error
  Rick Strahl
  Harvey Mushman
  Oct 22, 2014 @ 02:42pm
Hmmm...

There is a bug here with sending multiple messages with an attachment in .NET mode. It looks like when there's an attachment the first message sends subsequent ones do not.

For now the workaround is to use SendMail not SendMessage - ie. recreate the wwSmtp object for each send. I have to see what the issue is there - I don't see anything obvious wrong with this.

+++ Rick ---



When I copy and paste your example from the online documentation, the code works just fine.

Hum... something stinks like rotten fish!! <frown>

Then after another hour plus of comparing my code to your sample, I discovered one slight difference.

loSmtp.AddAttachment("C:\myFolder\myAcrobatFile.pdf","pdf/application")

VS.

loSmtp.cAttachment = "C:\myFolder\myAcrobatFile.pdf"

What I've discovered is cAttachment works in both classic nMailMode and in dot NET. On the other hand, AddAttachment only works on the first message inside the loop when dot NET nMailMode is selected.

Bug or Feature?

....James@Cranky.com! <g>

--hm

I'm not sure what you're saying. in MailMode 0 you can just send messages and leave the connection open. That only works in .NET. The classic version will always open and close connections for everything.

+++ Rick ---



Then the error is real and you need to take another look!

Reminder....

SendMessage() where the loSmtp.Connect() is before the SCAN loop of email addresses to send and where the loSmtp.Close() is after the ENDSCAN.

If I Connect() and Close() within the scan loop using the dotNET provider, then it works fine. But not as your documentation suggests where connection is held open for the duration of the loop.

This error is reproducible by copying your code from the online documentation and only changing this one parameter

loSmtp.nMailMode = 0

If you don't have this problem, I will be very surprised!

Thank you in advance for taking the time to look again.

--hm

You only need .NET from wherever you are sending the email not on the server - I just assumed you were doing this on your server FoxPro application.

+++ Rick ---



I'm running the VFP routing on my laptop. I would think all the code is executing on it and the only server in this case would be my mail server. In this case my version of Dot NET is 4.5. I will send you a screen shot offline.

Because your reply threw me a curve with the word "server" having dot net, I also looked at the system which the mail server sits on. Mind you this machine is strictly used for mail which is not Exchange so the need for dot NET has never come up before. It is running version 1.1 which I assume was installed at the time the machine was configured.

--hm


The default mode doesn't use .NET so you're going through a completely different pipeline to send emails.

If the .NET code doesn't work check for errors. Most likely you don't have .NET installed on your server.

+++ Rick ---



Discovered what was causing my problem although not sure why it does not work?

My setup code was the issue...

DO wwSmtp
LOCAL loSmtp as wwSmtp
loSmtp = CREATEOBJECT("wwSmtp")

* loSmtp.nMailMode = 0 && .NET 2 - classic (default)

By commenting out the nMailMode = 0 which I understood used the .NET version of WC, o.SendMessage looping inside the o.Connect to o.Close now works fine.

Who knew... :-)

--hm



Jim,

I just double checked this on my machine.

Can you setup the wwSmtp_sample.prg in the wwIpstuff_samples folder by just modifying for your mail server setup? One of the options in that file (commented out by default) is to make two SendMessage calls in a row. I ran that code and I got two email messages. Please check with that code... I used GMail for testing as well as my ISP here in Hood River and it worked with both. Maybe if it doesn't work try using a GMail or other public account to see if that gives different results.

If that doesn't work I'm not sure. It could be some mail server compatibility issue...

+++ Rick ---



OK, the my error still seems to exist when trying to send using the following code. The first address from my mailing list table goes without any problems be 2-n all show Incomplete-Session in the server logs.

A bit about my environment... My mail server is on the same LAN as my routine below which is running from my laptop.

Here is my code (excluding SMTP setup):

DO wwSmtp
LOCAL loSmtp as wwSmtp

*** setup smtp properties goes here along with opening table ***


SELECT('myList')
loSmtp.Connect()
SCAN

* prevent from sending twice
IF NOT EMPTY(result)
LOOP
ENDIF

loSmtp.cRecipient = ["] +ALLTRIM(STRTRAN(sender,',',' ')) + '" <' + ALLTRIM(email) +'>'
*loSmtp.cReplyTo = ALLTRIM(AcntName)
*** Now Sending ***

llResult = loSmtp.SendMessage()
* WAIT TIMEOUT .25
IF llResult
REPLACE Result WITH TRANSFORM(DATETIME())
ELSE
REPLACE Result WITH LEFT( loSmtp.cErrorMsg, 100)
ENDIF

ENDSCAN
loSmtp.Close()

I've left out all of the setup code for SMPT but basically copied and pasted in the sample code from the SendMessage documentation. And since the first message gets delivered correctly the problem is not in the configuration of SMTP.

Any help would be most welcome...















Rick Strahl
West Wind Technologies

Making waves on the Web
from Maui

Gravatar is a globally recognized avatar based on your email address. Re: SMTP - impomplete session error
  Rick Strahl
  Harvey Mushman
  Oct 22, 2014 @ 04:08pm
The workaround to this for now is to not use AddAttachment if you're running in a loop. Instead use loSmtp.cAttachment to set your attachment each time or leave it set.

So this works in the sample:

#IF .T.
*** Must manually connect first
loSmtp.Connect()

loSmtp.cAttachment = "c:\temp\trace.txt"

*** Send first recipient
?loSmtp.SendMessage("jjimy44@hotmail.com","","")
? loSmtp.cErrorMsg

*** Send second recipient
*loSmtp.AddAttachment("c:\temp\trace.txt")

loSmtp.cAttachment = "c:\temp\trace.txt"
loSmtp.cSubject = "Message number two"
?loSmtp.SendMessage("jjimy55@hotmail.com","","")
? loSmtp.cErrorMsg

*** Must close connection
loSmtp.Close()
#ENDIF

Looked to see and it appears this is a .NET issue that's not properly releasing the attachment object. And the actual attachment can't be reused more than once (so you can't create it and then use it again).

cAttachment just adds a new attachment each time so that works.

+++ Rick ---


When I copy and paste your example from the online documentation, the code works just fine.

Hum... something stinks like rotten fish!! <frown>

Then after another hour plus of comparing my code to your sample, I discovered one slight difference.

loSmtp.AddAttachment("C:\myFolder\myAcrobatFile.pdf","pdf/application")

VS.

loSmtp.cAttachment = "C:\myFolder\myAcrobatFile.pdf"

What I've discovered is cAttachment works in both classic nMailMode and in dot NET. On the other hand, AddAttachment only works on the first message inside the loop when dot NET nMailMode is selected.

Bug or Feature?

....James@Cranky.com! <g>

--hm

I'm not sure what you're saying. in MailMode 0 you can just send messages and leave the connection open. That only works in .NET. The classic version will always open and close connections for everything.

+++ Rick ---



Then the error is real and you need to take another look!

Reminder....

SendMessage() where the loSmtp.Connect() is before the SCAN loop of email addresses to send and where the loSmtp.Close() is after the ENDSCAN.

If I Connect() and Close() within the scan loop using the dotNET provider, then it works fine. But not as your documentation suggests where connection is held open for the duration of the loop.

This error is reproducible by copying your code from the online documentation and only changing this one parameter

loSmtp.nMailMode = 0

If you don't have this problem, I will be very surprised!

Thank you in advance for taking the time to look again.

--hm

You only need .NET from wherever you are sending the email not on the server - I just assumed you were doing this on your server FoxPro application.

+++ Rick ---



I'm running the VFP routing on my laptop. I would think all the code is executing on it and the only server in this case would be my mail server. In this case my version of Dot NET is 4.5. I will send you a screen shot offline.

Because your reply threw me a curve with the word "server" having dot net, I also looked at the system which the mail server sits on. Mind you this machine is strictly used for mail which is not Exchange so the need for dot NET has never come up before. It is running version 1.1 which I assume was installed at the time the machine was configured.

--hm


The default mode doesn't use .NET so you're going through a completely different pipeline to send emails.

If the .NET code doesn't work check for errors. Most likely you don't have .NET installed on your server.

+++ Rick ---



Discovered what was causing my problem although not sure why it does not work?

My setup code was the issue...

DO wwSmtp
LOCAL loSmtp as wwSmtp
loSmtp = CREATEOBJECT("wwSmtp")

* loSmtp.nMailMode = 0 && .NET 2 - classic (default)

By commenting out the nMailMode = 0 which I understood used the .NET version of WC, o.SendMessage looping inside the o.Connect to o.Close now works fine.

Who knew... :-)

--hm



Jim,

I just double checked this on my machine.

Can you setup the wwSmtp_sample.prg in the wwIpstuff_samples folder by just modifying for your mail server setup? One of the options in that file (commented out by default) is to make two SendMessage calls in a row. I ran that code and I got two email messages. Please check with that code... I used GMail for testing as well as my ISP here in Hood River and it worked with both. Maybe if it doesn't work try using a GMail or other public account to see if that gives different results.

If that doesn't work I'm not sure. It could be some mail server compatibility issue...

+++ Rick ---



OK, the my error still seems to exist when trying to send using the following code. The first address from my mailing list table goes without any problems be 2-n all show Incomplete-Session in the server logs.

A bit about my environment... My mail server is on the same LAN as my routine below which is running from my laptop.

Here is my code (excluding SMTP setup):

DO wwSmtp
LOCAL loSmtp as wwSmtp

*** setup smtp properties goes here along with opening table ***


SELECT('myList')
loSmtp.Connect()
SCAN

* prevent from sending twice
IF NOT EMPTY(result)
LOOP
ENDIF

loSmtp.cRecipient = ["] +ALLTRIM(STRTRAN(sender,',',' ')) + '" <' + ALLTRIM(email) +'>'
*loSmtp.cReplyTo = ALLTRIM(AcntName)
*** Now Sending ***

llResult = loSmtp.SendMessage()
* WAIT TIMEOUT .25
IF llResult
REPLACE Result WITH TRANSFORM(DATETIME())
ELSE
REPLACE Result WITH LEFT( loSmtp.cErrorMsg, 100)
ENDIF

ENDSCAN
loSmtp.Close()

I've left out all of the setup code for SMPT but basically copied and pasted in the sample code from the SendMessage documentation. And since the first message gets delivered correctly the problem is not in the configuration of SMTP.

Any help would be most welcome...















Rick Strahl
West Wind Technologies

Making waves on the Web
from Maui

Gravatar is a globally recognized avatar based on your email address. Re: SMTP - impomplete session error
  Rick Strahl
  Harvey Mushman
  Oct 22, 2014 @ 06:07pm
FWIW, I added a new method wwSmtp::ClearAttachments() that allows removing of attachments and fixed the .NET behavior where messages were being reused. So now rather than re-using the same objects they are stored and a new instance fired up when attachments are sent. IOW, it's now working the way it should in .NET mode.

It'll be in the next update.

+++ Rick ---



When I copy and paste your example from the online documentation, the code works just fine.

Hum... something stinks like rotten fish!! <frown>

Then after another hour plus of comparing my code to your sample, I discovered one slight difference.

loSmtp.AddAttachment("C:\myFolder\myAcrobatFile.pdf","pdf/application")

VS.

loSmtp.cAttachment = "C:\myFolder\myAcrobatFile.pdf"

What I've discovered is cAttachment works in both classic nMailMode and in dot NET. On the other hand, AddAttachment only works on the first message inside the loop when dot NET nMailMode is selected.

Bug or Feature?

....James@Cranky.com! <g>

--hm

I'm not sure what you're saying. in MailMode 0 you can just send messages and leave the connection open. That only works in .NET. The classic version will always open and close connections for everything.

+++ Rick ---



Then the error is real and you need to take another look!

Reminder....

SendMessage() where the loSmtp.Connect() is before the SCAN loop of email addresses to send and where the loSmtp.Close() is after the ENDSCAN.

If I Connect() and Close() within the scan loop using the dotNET provider, then it works fine. But not as your documentation suggests where connection is held open for the duration of the loop.

This error is reproducible by copying your code from the online documentation and only changing this one parameter

loSmtp.nMailMode = 0

If you don't have this problem, I will be very surprised!

Thank you in advance for taking the time to look again.

--hm

You only need .NET from wherever you are sending the email not on the server - I just assumed you were doing this on your server FoxPro application.

+++ Rick ---



I'm running the VFP routing on my laptop. I would think all the code is executing on it and the only server in this case would be my mail server. In this case my version of Dot NET is 4.5. I will send you a screen shot offline.

Because your reply threw me a curve with the word "server" having dot net, I also looked at the system which the mail server sits on. Mind you this machine is strictly used for mail which is not Exchange so the need for dot NET has never come up before. It is running version 1.1 which I assume was installed at the time the machine was configured.

--hm


The default mode doesn't use .NET so you're going through a completely different pipeline to send emails.

If the .NET code doesn't work check for errors. Most likely you don't have .NET installed on your server.

+++ Rick ---



Discovered what was causing my problem although not sure why it does not work?

My setup code was the issue...

DO wwSmtp
LOCAL loSmtp as wwSmtp
loSmtp = CREATEOBJECT("wwSmtp")

* loSmtp.nMailMode = 0 && .NET 2 - classic (default)

By commenting out the nMailMode = 0 which I understood used the .NET version of WC, o.SendMessage looping inside the o.Connect to o.Close now works fine.

Who knew... :-)

--hm



Jim,

I just double checked this on my machine.

Can you setup the wwSmtp_sample.prg in the wwIpstuff_samples folder by just modifying for your mail server setup? One of the options in that file (commented out by default) is to make two SendMessage calls in a row. I ran that code and I got two email messages. Please check with that code... I used GMail for testing as well as my ISP here in Hood River and it worked with both. Maybe if it doesn't work try using a GMail or other public account to see if that gives different results.

If that doesn't work I'm not sure. It could be some mail server compatibility issue...

+++ Rick ---



OK, the my error still seems to exist when trying to send using the following code. The first address from my mailing list table goes without any problems be 2-n all show Incomplete-Session in the server logs.

A bit about my environment... My mail server is on the same LAN as my routine below which is running from my laptop.

Here is my code (excluding SMTP setup):

DO wwSmtp
LOCAL loSmtp as wwSmtp

*** setup smtp properties goes here along with opening table ***


SELECT('myList')
loSmtp.Connect()
SCAN

* prevent from sending twice
IF NOT EMPTY(result)
LOOP
ENDIF

loSmtp.cRecipient = ["] +ALLTRIM(STRTRAN(sender,',',' ')) + '" <' + ALLTRIM(email) +'>'
*loSmtp.cReplyTo = ALLTRIM(AcntName)
*** Now Sending ***

llResult = loSmtp.SendMessage()
* WAIT TIMEOUT .25
IF llResult
REPLACE Result WITH TRANSFORM(DATETIME())
ELSE
REPLACE Result WITH LEFT( loSmtp.cErrorMsg, 100)
ENDIF

ENDSCAN
loSmtp.Close()

I've left out all of the setup code for SMPT but basically copied and pasted in the sample code from the SendMessage documentation. And since the first message gets delivered correctly the problem is not in the configuration of SMTP.

Any help would be most welcome...















Rick Strahl
West Wind Technologies

Making waves on the Web
from Maui

© 1996-2024