Gambas Documentation
Application Repository
Code Snippets
Compilation & Installation from source code
Components
gb
gb.args
gb.cairo
gb.chart
gb.clipper
gb.complex
gb.compress
gb.crypt
gb.data
gb.db
gb.db.form
gb.db.mysql
gb.db.odbc
gb.db.postgresql
gb.db.sqlite2
gb.db.sqlite3
gb.db2
gb.dbus
gb.dbus.trayicon
gb.debug
gb.desktop
gb.desktop.gnome.keyring
gb.desktop.x11
gb.eval
gb.eval.highlight
gb.form
gb.form.dialog
gb.form.editor
gb.form.htmlview
gb.form.mdi
gb.form.print
gb.form.stock
gb.form.terminal
gb.gmp
gb.gsl
gb.gtk
gb.gtk.opengl
gb.gtk3
gb.gtk3.opengl
gb.gtk3.webview
gb.gui
gb.gui.opengl
gb.gui.qt
gb.gui.qt.ext
gb.gui.qt.opengl
gb.gui.qt.webkit
gb.gui.trayicon
gb.gui.webview
gb.hash
gb.highlight
gb.image
gb.image.effect
gb.image.imlib
gb.image.io
gb.inotify
gb.jit
gb.libxml
gb.logging
gb.map
gb.markdown
gb.media
gb.media.form
gb.memcached
gb.mime
gb.mongodb
gb.mysql
gb.ncurses
gb.net
gb.net.curl
gb.net.pop3
gb.net.smtp
_smtpclient
Net
SmtpClient
_new ?
Add
AddHeader
Alternative
Authentication
Automatic
Bcc
Body
Cc
Clear
Count
CramMD5
Debug
Encrypt
FormatDate
From
Host
InReplyTo
Login
MessageId
Password
Plain
Port
Send
Subject
To
User
gb.openal
gb.opengl
gb.opengl.glsl
gb.opengl.glu
gb.opengl.sge
gb.openssl
gb.option
gb.pcre
gb.pdf
gb.poppler
gb.qt4
gb.qt4.ext
gb.qt4.opengl
gb.qt4.webkit
gb.qt4.webview
gb.qt5
gb.qt5.ext
gb.qt5.opengl
gb.qt5.webkit
gb.qt5.webview
gb.qt6
gb.qt6.ext
gb.qt6.opengl
gb.qt6.webview
gb.report
gb.report2
gb.scanner
gb.sdl
gb.sdl.sound
gb.sdl2
gb.sdl2.audio
gb.settings
gb.signal
gb.term
gb.test
gb.util
gb.util.web
gb.v4l
gb.vb
gb.web
gb.web.feed
gb.web.form
gb.web.gui
gb.xml
gb.xml.html
gb.xml.rpc
gb.xml.xslt
Controls pictures
Deprecated components
Developer Documentation
Development Environment Documentation
Documents
Error Messages
Gambas Playground
How To's
Language Index
Language Overviews
Last Changes
Lexicon
README
Search the wiki
To Do
Topics
Tutorials
Wiki License
Wiki Manual

SmtpClient (gb.net.smtp)

This class implements a SMTP client.

This class is creatable.

Constants
Automatic   Use this constant to try any authentication protocol until one works.
CramMD5   Constant for the SMTP "CRAM-MD5" authentication protocol.
Login   Constant for the SMTP "LOGIN" authentication protocol.
Plain   Constant for the SMTP "PLAIN" authentication protocol.

Static methods
FormatDate   Format a date according to the RFC 822 syntax.

Properties
Alternative   Returns or sets if mail attachments are actually different alternatives of the same data. For example, a mail encoded in HTML, in UTF-8, or only in ASCII.
Authentication   Return or set the SMTP authentication protocol.
Bcc   Returns or sets the list of "Bcc" (i.e. blind carbon copy) recipients e-mail addresses.
Body   Return or set the mail body.
Cc   Returns or sets the list of "Cc" (i.e. carbon copy) recipients e-mail addresses.
Count   Return the number of parts in the current mail.
Debug   Return or set if the debugging mode is enabled for that SmtpClient.
Encrypt   Return or set the SMTP encryption method.
From   Returns or sets the return address of the mail.
Host   Returns or sets the SMTP server that will receive the mail.
InReplyTo   Return or set the In-Reply-To header.
MessageId   Return or set the Message-ID header.
Password   Return or set the user password.
Port   Returns or sets the SMTP port used by the SMTP server.
Subject   Returns or sets the mail subject.
To   Returns or sets the list of "To" recipients e-mail addresses.
User   Return or set the user login.

Methods
Add   Adds an attachment to the mail.
AddHeader   Add a custom header to the mail.
Clear   Clear the attachments.
Send   Send the mail.

Plain Text Example


  Dim Email As New SmtpClient

  Email.Host = "MySMTPServer"
  Email.User = "MyUserName"
  Email.Password = "MyPassword"

  Email.From = "[email protected]"
  Email.To.Add("[email protected]")

  Email.Subject = "Hello World"
  Email.Body = "Hello World"

  Email.Send

HTML Example


  Dim Email As New SmtpClient
  Dim HtmlBody As String

  Email.Host = "MySMTPServer"
  Email.User = "MyUserName"
  Email.Password = "MyPassword"

  Email.From = "[email protected]"
  Email.To.Add("[email protected]")

  Email.Subject = "Hello World"
  Email.Body = "Hello World"

  HtmlBody = "<html><body>Hello <b>World</b></body></html>"
  Email.Alternative = True
  Email.Add(HtmlBody, "text/html")

  Email.Send