Joho the BlogHow to send email using RealBasic - Joho the Blog

How to send email using RealBasic

It took a bunch of googling (thanks!) and some experimentation, but the following seems to work on a Mac (snow leopard) to send email programmatically, using RealBasic:

Dim mail as EmailMessage
Dim SMTPSocket1 as SMTPSocket

// create an instance:
SMTPSocket1 = new SMTPSocket

// The name of an available SMTP server:
SMTPSocket1.address = “smtp.YOURSERVER.com”
// The port number of the server:
SMTPSocket1.port = 25
// Your username for the server, if nec.
SMTPSocket1.Username=”[email protected]
// Your password:
SMTPSocket1.Password=”yourpwd”

// Create a new message:
mail = New EmailMessage
// The address you want it to come from:
mail.fromAddress= “[email protected]
mail.subject= “Your Subject”
// The message:
mail.bodyPlainText = “Testing. Testing. Is this thing on?”
// Alternatively, encode message in HTML:
mail.BodyHTML = “<u>Testing</u> Is this thing <blink>on</blink>?”
// If you want a header:
mail.headers.appendHeader “X-Mailer”,”REALbasic SMTP”

// The address you’re sending it to:
mail.AddRecipient “[email protected]
// cc someone:
mail.addCCRecipient “[email protected]

// Add it to list of messages:
SMTPSocket1.messages.append mail
// Send message:
SMTPSocket1.SendMail

// Wait for the sending to be done if you’re going to send another
while SMTPSocket1.BytesLeftToSend > 0
  SMTPSocket1.poll
wend

Please correct any boneheaded errors I’ve made. Thanks.

Comments are closed.


Web Joho only

Comments (RSS).  RSS icon