The sample demonstrates sending e-mail while staying responsive to user actions. User can abort sending process by closing the app.
Note: This sample code is for Visual Basic only. ASP does not support events.
By default, MailBee does not processes Windows events when performing mail operation. This gives maximum performance and fits fine for web applications (such as ASP ones).
Desktop applications, however, usually give user an option to interact with the app even when it is busy (e.g. sends e-mail).
To let MailBee process Windows events, EnableEvents property of SMTP object must be set to True before connecting to SMTP server.
MailBee is also capable of firing its own events (such as sending progress). See EnableEvents property documentation for details.
' Declare mailer object global to control
' it within different subroutines
' User clicked the button. Must send e-mail
Private Sub Command1_Click()
' Allow SMTP object to process Windows
' events during operation
objSMTP.EnableEvents = True
' Unlock SMTP component
objSMTP.LicenseKey = "put your license key here"
' Set SMTP server name
objSMTP.ServerName = "mail.server.com"
' Set message properties
objSMTP.FromAddr = "email@example.com"
objSMTP.ToAddr = "firstname.lastname@example.org"
objSMTP.Subject = "Hi"
objSMTP.BodyText = "This is large message"
' Add large attachment so message sending
' would take some time
' Send it!
' Close the connection
' App launched, create mailer object but
' do not send any e-mail yet
Private Sub Form_Load()
' Create mailer component
Set objSMTP = CreateObject("MailBee.SMTP")
' User closed the app
Private Sub Form_Unload(Cancel As Integer)
' If e-mail is still being sent,
' abort mail operation
If objSMTP.Busy Then objSMTP.Abort