logo

Let’s just see what happens

Mobile Version

About me

Newsletter

Videos

Speaker

Hard to Read? Choose a style: Style 1 Style 2 Style 3 Default Toggle Sidebars

How to send email using RealBasic

Posted on February 7th, 2010

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=”yourname@yourserver.com”
// Your password:
SMTPSocket1.Password=”yourpwd”

// Create a new message:
mail = New EmailMessage
// The address you want it to come from:
mail.fromAddress= “your@address.com”
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 “person@somwehere.com”
// cc someone:
mail.addCCRecipient “another@recipient.com”

// 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.

Tagged with: email • realbasic

Previous: « After press conferences, what? || Next: Cloud capitalism’s threat to cloud culture »

Leave a Reply


Web Joho only

 

Entries (RSS)
Copy this link as RSS address

Comments (RSS).

Creative Commons License
Joho the Blog by David Weinberger is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License. Share it freely, but attribute it to me, and don't use it commercially without my permission.

Joho the blog uses WordPress blogging software.
Thanks, WordPress!