Alaska Software Inc. - SMTPclient Problems
Username: Password:
AuthorTopic: SMTPclient Problems
William HeplerSMTPclient Problems
on Wed, 11 Oct 2017 21:08:12 -0700
I am having a lot of trouble reliably sending email using the SMTPlcient 
components.  All I want to do is send a "batch" of emails where each 
invoice (a generated PDF file) is sent to a different email recipient 
address with a short text in the email, and a subject line.

I am having no problem sending to different recipient with a customized 
subject line, but when I enclose an attachment, it often (but not 
always!) causes the text in the email to be blank.  The Subject Line and 
the Recipient are correct!

This seems very flaky.  Should I just buy a library from MarshallSoft 
(or someone else) ??

Here is an example of the code (that works).  Prior to this code being 
invoked, I have opened the connection and created "oMail").   Small 
modifications to this code to make it more useful cause the message in 
cText to NOT be included in the eMail.


 Example code
static function SendEmail( oSmtp, nNo, oMail, cRecipient, ;
                            oLog, cLogLevel)
	local cText
	local cPurportedSender
	local oSender
	local oRecipient
	local cFileToAttach
	local aHeaders, aContent

	 oMail was previously created and gets reused
	oMail:init()

	cPurportedSender := "Billing Department-"+str(nNo,1)+ ;
		" do-not-reply@somewhere.com"
	cFileToAttach    := "SomePDF-"+str(nNo,1)+".pdf"

	oSender    := MailAddress():new( cPurportedSender )
	oRecipient := MailAddress():new( cRecipient )

	cText := "Test of Auto Email to Self - " + CR_LF + CR_LF
	cText += "Cheers or beers to Two People" + CR_LF
	cText += "  Bill from Send In Blue file, to "+cRecipient + CR_LF
	cText += "-->  Try.prg version of test <--" + CR_LF
	cText += "Dated on "+dtoc(date())+' '+time() + CR_LF
	cText += 'We hope this includes the attachment:'+ ;
              cFileToAttach + CR_LF
	cText += 'The LogLevel is: '+cLogLevel + CR_LF

	
	 This works, the order in which
	oMail:setFrom     ( oSender     )
	oMail:setSubject  ( "TryThree-Msg#"+str(nNo,1)+" " + ;
	  cFileToAttach +" "+dtoc(date())+" "+time() )
	oMail:setMessage  ( cText       )

	oMail:addRecipient( oRecipient  )

	if file( cFileToAttach )
	      oMail:attachFile( cFileToAttach )
	else
	       do some error routine
	endif

	/* --------- I have tried inspecting these, but it does not seem
                       to tell me anything.
	   aHeaders := oMail:getAllHeaders()
	   aContent := oMail:getContent()

	   WriteHeaders3( aHeaders, aContent, str(nNo,1)+' Some MSG)
	-------------------- (/

	IF oSmtp:send( oMail )
	      oLog:write( "Message sent  NO:"+str(nNo,1) )
	ELSE
	      oLog:write( "Message NOT sent NO:"+str(nNo,1) )
	ENDIF
return( nil )


Bill Hepler
Crafted Industrial Software
Peter AlderliestenRe: SMTPclient Problems
on Thu, 12 Oct 2017 11:35:21 +0200
Bill,

> I am having no problem sending to different recipient with a customized 
> subject line, but when I enclose an attachment, it often (but not 
> always!) causes the text in the email to be blank.  The Subject Line and 
> the Recipient are correct!

Make sure that adding attachments is the very last action in constructing
the email.

Peter
Jonathan LeemingRe: SMTPclient Problems
on Thu, 12 Oct 2017 11:36:36 -0600
On 10/12/2017 3:35 AM, Peter Alderliesten wrote:
> Bill,
> 
>> I am having no problem sending to different recipient with a customized
>> subject line, but when I enclose an attachment, it often (but not
>> always!) causes the text in the email to be blank.  The Subject Line and
>> the Recipient are correct!
> 
> Make sure that adding attachments is the very last action in constructing
> the email.
> 
> Peter
> 

Hi Bill,

I used to use MarshallSoft's SEE4XB email library but since we use GMail 
for our server and they require SSL we had to use the stunnel proxy 
server as well.  However now with Xbase++ 2.0 which supports SSL 
directly we no longer need stunnel and the email process appears to be 
quicker.

As to your issue with attachments causing problems with the email we 
send out 50-100 emails a day and 80% of these would have attachments. 
The process runs flawlessly so I have no problems endorsing Xbase 
SMTPClient.   After reading Peter's comment regarding adding attachments 
last I double checked my send email function and am adding the 
attachment last.

The only significant difference with your code and mine is that although 
I may pass the oSmtp object I never "reuse" the oMail object.  I always 
create a new oMail MIMIMessage().  I also am always using a GMail server 
to send mail from the various accounts.

Hope you get this resolved... random / flaky issues can be trying!

Regards... Jonathan
Rudolf ReinthalerRe: SMTPclient Problems
on Fri, 20 Oct 2017 13:41:40 +0200
Hello,
look a Chilkat,its ActiveX and, works great, and has a lot more 
interesting things.
regards
Rudolf


Am 12.10.2017 um 19:36 schrieb Jonathan Leeming:
> On 10/12/2017 3:35 AM, Peter Alderliesten wrote:
>> Bill,
>>
>>> I am having no problem sending to different recipient with a customized
>>> subject line, but when I enclose an attachment, it often (but not
>>> always!) causes the text in the email to be blank.  The Subject Line and
>>> the Recipient are correct!
>>
>> Make sure that adding attachments is the very last action in constructing
>> the email.
>>
>> Peter
>>
> 
> Hi Bill,
> 
> I used to use MarshallSoft's SEE4XB email library but since we use GMail 
> for our server and they require SSL we had to use the stunnel proxy 
> server as well.  However now with Xbase++ 2.0 which supports SSL 
> directly we no longer need stunnel and the email process appears to be 
> quicker.
> 
> As to your issue with attachments causing problems with the email we 
> send out 50-100 emails a day and 80% of these would have attachments. 
> The process runs flawlessly so I have no problems endorsing Xbase 
> SMTPClient.   After reading Peter's comment regarding adding attachments 
> last I double checked my send email function and am adding the 
> attachment last.
> 
> The only significant difference with your code and mine is that although 
> I may pass the oSmtp object I never "reuse" the oMail object.  I always 
> create a new oMail MIMIMessage().  I also am always using a GMail server 
> to send mail from the various accounts.
> 
> Hope you get this resolved... random / flaky issues can be trying!
> 
> Regards... Jonathan
> 


---
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
https://www.avast.com/antivirus