Handling events
' Declare mailer object global to control ' it within different subroutines Dim objSMTP ' 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 = "me@mydomain.com" objSMTP.ToAddr = "you@yourdomain.com" objSMTP.Subject = "Hi" objSMTP.BodyText = "This is large message" ' Add large attachment so message sending ' would take some time objSMTP.AddAttachment "C:\Data\Bigfile.avi" ' Send it! objSMTP.Send ' Close the connection objSMTP.Disconnect End Sub ' 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") End Sub ' 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 End Sub
Not applicableSee Also: