Followed instructions from Documents on EMail

Not sure offhand. You might take a look at the Email example projects for starters:


Also check out the Lang Ref page:

If you like to send emails, please check MBS Xojo CURL Plugin and the CURLEmailMBS class.
Our example projects show you how to build and send emails with attachments, multiple recipients, html & plain text.


To clarify my posting: the built-in classes are fine for a lot of Xojo developers.

But if you need more, you are welcome to try alternatives like our plugin classes to send/receive emails.

If you have questions about our plugin, please do not hesitate to contact us.

Otherwise just ignore this post.

1 Like

The ‘context’ was how to get the code the OP has working. Ergo the post is out of context.

Precedent set.

1 Like

The broader context is “How do I send emails from Xojo?” Seasoned developers know that there are many situations in which the built-in classes are insufficient. Therefore, alternative solutions are necessary. While Christian’s comments do not directly address the OP question, they are still germane to the broader issue.


Well said.

With that, could everyone please return to the topic at hand?

That’s your assumed broader context. Why assume when the known context is right in front of us and address what we do know, not what we don’t. For example, the broader context could well have been ‘I am learning Xojo and have picked a random documentation code snippet and cannot get it to work’ with a follow-up (i.e. still not assuming here) ‘I have not done much with classes’. This was met with an advert.

Don’t think anyone is disagreeing with you.

As before, your assumed broader issue.

The irony is that the question was answered but my follow-up (which rounded out the answer to the direct question being asked) was farmed out to the ‘irrelevant’ thread. So now (unlike earlier) this thread does not have an answer to the question (it did earlier) but does have an advert.

Just saying :slight_smile:

1 Like

Yes Kem. As per my post above, the solution to the question asked was farmed out to the irrelevant thread. If you would be so kind as to replace it here - the OP’s question will then be answered which is all I (and, according to the question) the OP wanted in the first place.


Back to the topic.

@John_McDonald, did you try the suggestion from @Paul_Lefebvreto play with the examples coming with Xojo? They show how to use it.

What is the status of the project?

Did you try SMTPSecureSocket class to benefit from TLS encryption, which is certainly required for gmail?

Did you put MailSocket as item on a window or add it as property to the window and instantiate it in code? Just having it as local variable won’t be enough.

I am at a complete loss here. Back to topic ? You mean the one that your spam derailed, right ? You have to be joking. Also why ask if John tried the examples ? He asked about making something specific work. He did not ask for samples and I find the timing of @Paul_Lefebvre’s post (intermixed, seemingly injected on the face of it) quizzing to say the least.

The problem @John_McDonald was facing was already solved but the thread was split and the last part of the answer was siphoned off to the thread starting with the ‘Irrelevant…’ title.

If this is what this forum is about then please ban me @Xojo. I am clearly wasted and indeed wasting my time here.

I have, in the last couple of days, lost an enormous amount of respect for what I (and I guarantee you a great deal of others) believed this place was about.

When I came here years ago, I immediately noticed what I believed to be a great deal of spam but bit my tongue. Well I am at the point that I do not need to do that anymore so I have commented. Any objective person sees that this was spam and shame on @Xojo for not having the fortitude to call it out as I did.

Enough said I believe. Happy to have stood up for what is correct, and deep down objective, rational and logical members know that what I have said is, indeed, correct but let’s not let what is right stand in the way of relationships and economics, as it appears from the outside, to be.

1 Like

The OP was experiencing compile errors. In my first post I made a suggestion and asked a question. I’ve yet to see a response to that.

1 Like

Alternative options should always be presented. The user may believe that SMTPSocket is the only way, or maybe even the best way. In my opinion, it’s probably the worst way. As a developer with experience in this department, why would I not share that experience?

To a degree, that’s why Christian is doing: sharing an alternative.

Here’s another alternative: don’t use your own SMTP server. If the project can afford it, farm your emails out to a third party like MailGun, SendGrid, or (my personal favorite) Postmark. You’ll submit the email via HTTP using the URLConnection socket, which is easier and gives you more feedback. Your email will be more deliverable too.

If you really want to get SMTPSocket going, the issue likely scoping. The socket needs to exist long enough to finish delivery. If it were placed on a window that is closing, or the app is exiting, the socket probably goes out of scope before it finishes its work. It’s a very common usage mistake.

Personally I use the SSLSocket for both sending and receiving mail. It’s only text, after all. I subclass SSLSocket and give the subclass the characteristics it needs, including a timer.

The OP was experiencing compile errors. In my first post I made a suggestion and asked a question. I’ve yet to see a response to that.”

Sorry, life has taken me away from my projects. Thank you for the answers o far. I am just now reading them all and working on implementing them.

The email is a simple notice that is sent to our vendors when they sign up for an event. As part of the sign up process a confirmation email is sent to them. Nothing fancy or complex.

Thank you again, I will start digging into the answers as time permits.


No prob. Feel free to pose more questions as and when.

(Meanwhile I’m feeling cheerful as I get my Covid jab in two days).


Okay, so I have made the appropriate corrections (thanks for the pics… really helped to get it set up!).

The program compiles and runs, I click the appropriate button and no errors… and no mail too! Not sure what I am missing.
// *********** JHGC ************
’ Ian McDonald - Develper/Maintainer
’ (999) 999-9999
’ Dump Microsoft! Go Penquin Computing!
// *********** JHGC ************

// Variable Declarations
Var MailSocket as SMTPSecureSocket
MailSocket = new SMTPSecureSocket

// Test format of email before moving forward...
Var blnTest As Boolean = modSysFunc.mthEmailCheck( txtVendorEmail.Value.ToText )

// Code in Action!
If( blnTest = True ) Then
  MailSocket.Address = "" '""
  MailSocket.Port =  143 ' 465
  MailSocket.ConnectionType = SMTPSecureSocket.TLSv1
  MailSocket.SMTPConnectionMode = SMTPSecureSocket.ModeSSLTLS
  MailSocket.Secure = True
  'MailSocket.UserName = ""
  'MailSocket.Password = "**************"
  MailSocket.UserName = ""
  MailSocket.Password = "****************"
  Var email As New EmailMessage
  email.FromAddress = ""
  email.Subject = "Hello, world!"
  email.BodyPlainText = "I love Xojo!"
  email.AddRecipient( "" )
  MailSocket.Messages.AddRow( email )
  MessageBox( "It clicked... did it werk?" )
  MessageBox( "Apparently you do not know how to write an email address..." )
End If

Where have you put this code?

And I would have thought that MailSocket.Address needs to be the address of the remote smtp server.

MailSocket must be a property of the window, not a local variable.
And the sending is asynchronous, so your message box will come before it sends.

You need to make MailSocket and probably email be non-local variables. Otherwise at the end of whereever you’ve put this, they just vanish. Poof!

Are you using an email address instead of a server address?

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.