From Xojo Documentation
You can send email using SMTP (Standard Mail Transfer Protocol) protocol and receive email using POP3 (Post Office Protocol) protocol.
You have to provide your own SMTP server to actually send the email. You can choose to use your ISP mail server or a 3rd party server such as Gmail. Most SMTP servers will require you to log on with a username and password and require a secure connect.
In order to use Gmail to send you'll need to enable the "allow less secure apps" option as described in this Google support document: https://support.google.com/accounts/answer/6010255
With that enabled, this code is able to send a simple email:
MailSocket.Port = 465
MailSocket.ConnectionType = SMTPSecureSocket.TLSv1
MailSocket.SMTPConnectionMode = SMTPSecureSocket.ModeSSLTLS
MailSocket.Secure = True
MailSocket.UserName = <YourGmailUserName>
MailSocket.Password = <YourGmailPassword>
Var email As New EmailMessage
email.FromAddress = "email@example.com"
email.Subject = "Hello, world!"
email.BodyPlainText = "I love Xojo!"
The EmailMessage class has even more properties and methods to set HTML message text, headers and CC recipients.
You can also add attachments to your email using the EmailAttachment class.
To receive email, you use the POP3SecureSocket class. This class connects to your POP3 server and requests mail messages. As messages are received, the MessageReceived event handler is called with the email supplied as an EmailMessage parameter.
POP3SecureSocket has many events, properties and methods to allow you to receive POP3 email.
|Many email services use IMAP instead of POP. If you need IMAP, consider looking into the MonkeyBread Software Plugin.|