New topic: 

Send mail using SMTP

<http://forums.realsoftware.com/viewtopic.php?t=47439>

         Page 1 of 1
   [ 3 posts ]                 Previous topic | Next topic          Author  
Message        abhimmit          Post subject: Send mail using SMTPPosted: Fri 
Mar 29, 2013 3:03 am                         
Joined: Mon Jan 10, 2011 1:29 pm
Posts: 13                Why the below doesn't work.

  Dim mail as new EmailMessage, d as new date 
  Dim file as new EmailAttachment
  Dim i as Integer
  Dim s as String
  dim SMTPSocket1 as SMTPSecureSocket
  
  SMTPSocket1  = new SMTPSecureSocket
  SMTPSocket1.Address = "smtp.gmail.com"
  SMTPSocket1.ConnectionType = SMTPSecureSocket.TLSv1
  SMTPSocket1.Secure = true
  SMTPSocket1.Port =  587 
  SMTPSocket1.Username = "User-ID"
  SMTPSocket1.Password = "PWD"
  
  mail = New EmailMessage
  mail.fromAddress="FROM ADDRESS"
  mail.subject= "File sent from My COMPUTER"
  mail.bodyPlainText = "Dear sir" + chr(13) + "This file sent from My PC" + 
chr(13) + "Plain text"
  mail.bodyHTML =  "Dear sir" + chr(13) + "This file sent from My PC" + 
str(d.ShortDate) + " "  + str(d.ShortTime)  + chr(13) + "HTML text"
  mail.headers.appendHeader "X-Mailer","From My pc"
  
  mail.addRecipient("RECIPIENT ADDRESS")
  
  file = New EmailAttachment
  file.loadFromFile GetFolderItem("FOLDER + FILE")
  mail.attachments.append file 
  
  SMTPSocket1.Messages.Append mail
  SMTPSocket1.SendMail
  SMTPSocket1.Flush   
                             Top                timhare          Post subject: 
Re: Send mail using SMTPPosted: Fri Mar 29, 2013 3:17 am                        
 
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12183
Location: Portland, OR  USA                Either
A) Flush tosses the message before it can be sent.
or
B) The socket goes out of scope and is destroyed before it can send the message.

Use a property of the window (or app or a module) so it lives long enough to 
send the message.  And don't call Flush.   
                             Top                abhimmit          Post subject: 
Re: Send mail using SMTPPosted: Fri Mar 29, 2013 4:39 am                        
 
Joined: Mon Jan 10, 2011 1:29 pm
Posts: 13                Thanks timhare,

I have added the following at the end;

  App.DoEvents(250)
  if SMTPSocket1.SSLConnecting then
  App.DoEvents(500)
  end if

But no still no luck.   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 3 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to