Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Dec 09, 2019 7:30 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: SMTP Anomaly, Sending Problems using SMTPSecureSocket
PostPosted: Tue Oct 16, 2012 11:47 am 
Offline

Joined: Sat Jul 24, 2010 12:20 am
Posts: 52
Hi,

First I Have combed the forums and the web and have read everything I can find and nothing explines what I have run into.

I draged an Object onto the screen and set the Super to SMTPSecureSocket. The code below has two methods of sending, One dynamically creating the SMTPSecureSocket and One using the one that is on the form. If chkTestDynamic it runs the dynamic. Now my first problem.

The only one that works is the Dynamic SMTPSecureSocket version, where it's created programmatically.

The other Option Doesn't. Am I doing something wrong? I Am totally lost.

This program will send approximately 300 emails with pdf attachments. The other problem I'm seeing using the dynamic version because it works is that it doesn't seem to send them all, it goes through the entire list but only a few of them get received. I'm sure this is due to something I'm doing, just don't know what.

This is the only code that touches the SMTPSecureSocket.

Thanks for any help you can provide.

Rich Albrecht

If chkTestDynamic.Value then

Dim MailSocket as SMTPSecureSocket
MailSocket = New SMTPSocket1
MailSocket.address = gsSMTPServer
MailSocket.port = gnPort
MailSocket.username = gsSMTPUserID
MailSocket.password = gsSMTPPassword
MailSocket.Secure = true
MailSocket.ConnectionType = MailSocket.SSLv3
MailSocket.messages.append GetEmailMessage(lsPersonID, lsEmail, lfiPDF, lsName)
lblStatus.Text = "Sending to " + lsName + "..."
lblStatus.Refresh
MailSocket.SendMail //send message
MailSocket.Flush
while MailSocket.BytesLeftToSend > 0
MailSocket.poll
wend
else

SMTPSocket1.address = gsSMTPServer
SMTPSocket1.port = gnPort
SMTPSocket1.username = gsSMTPUserID
SMTPSocket1.password = gsSMTPPassword
SMTPSocket1.Secure = true
SMTPSocket1.ConnectionType = SMTPSocket1.SSLv3
SMTPSocket1.messages.append GetEmailMessage(lsPersonID, lsEmail, lfiPDF, lsName)
lblStatus.Text = "Sending to " + lsName + "..."
lblStatus.Refresh
SMTPSocket1.SendMail //send message
SMTPSocket1.Flush
while SMTPSocket1.BytesLeftToSend > 0
SMTPSocket1.poll
wend

end


Top
 Profile  
Reply with quote  
 Post subject: Re: SMTP Anomaly, Sending Problems using SMTPSecureSocket
PostPosted: Thu Oct 18, 2012 3:33 am 
Offline
User avatar

Joined: Fri Oct 28, 2005 7:05 am
Posts: 565
Location: Emsworth, UK
Hawkcode wrote:
Am I doing something wrong?
Yep.

.Flush causes a socket to immediately dump it's transmit buffer.

So, you tell your socket to .SendMail, then tell it to .Flush and then enter a loop checking .BytesAvailable, which will equal zero on the first iteration after .Poll, causing the loop to finish well before the mail has been sent.


.Flush and .BytesAvailable are methods of the underlying TCPSocket that SMTPSecureSocket is descended from. SMTPSecureSocket uses the properties, methods and events of the underlying class for it's own use and declares it's own 'higher level' properties, methods and events. So, you (probably) want to avoid using .Flush and .BytesAvailable in favour of the properties, methods and events declared by SMTPSecureSocket.

You also have a scope issue going on with your 'dynamic' code.

The SMTPSecureSocket can queue mail and send it all at once. So .AppendMessage probably wants to be in a loop, which appends more than one message at a time before calling .SendMail

Personally I would start again and use the .MailSent event handler to find when the socket has finished processing it's send queue. A desktop app will have to keep the form and application loaded until the mail queue has been fully processed (quite a while for 300 pdfs). The form's .CanClose event would be the place to stop the application quitting before the mail has been sent.

_________________
Yes it's me in the avatar


Top
 Profile  
Reply with quote  
 Post subject: Re: SMTP Anomaly, Sending Problems using SMTPSecureSocket
PostPosted: Thu Oct 18, 2012 8:09 am 
Offline

Joined: Sat Jul 24, 2010 12:20 am
Posts: 52
Thank you so much.

I will implement changes later today and post results.

Thanks again

Rich


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group