EMail object

The EMail object provides a range of events that let the user know how the message delivering goes. In order to create a licensed EMail object, you have to use NewEmail property. If you deploy an application that uses CreateObject or New statements in order to create new EMail objects, it fails because the EMail object is a licensed ActiveX component. The New and CreateObject statements work only on machines where the ExEMail component was licensed for design mode. A Message object sent notifications ( events ) to the application only if Notifier property points to an EMail object. Use the EMail object to handle message' notifications, or for retrieving a description for the last error occured. Use the NewMessage to create licensed Message objects at runtime.

For instance, the following sample shows how to send an email message using non-blocking mode:

Dim WithEvents e As EMail

Private Sub e_EndSend(ByVal Msg As EXEMAILLibCtl.IMessage)
    Debug.Print e.Error(Msg.LastError)
End Sub

Private Sub Form_Load()
    ' Creates an EMail object, that will receive Message notifications
    Set e = Runtime1.NewEMail()
    ' Creates a Message object
    Dim m As Message
    Set m = Runtime1.NewMessage()
   
' Message' notifications are sent through EMail object
    Set m.Notifier = e
    ' Sends a message to one user
    m.Send "m@malibu.com", "marfa@cool2.com", "Test", "The message has one attchament", "c:\winnt\system32\setup.exe"
End Sub

The following sample shows how to send an email message using blocking mode:

Private Sub Form_Load()
    Dim e As EMail
    ' Creates an EMail object, that will receive Message notifications
    Set e = Runtime1.NewEMail()
    ' Creates a Message object
    Dim m As Message
    Set m = Runtime1.NewMessage()
   
' Sends a message to one user
    Debug.Print e.Error(m.Send("m@malibu.com", "marfa@cool2.com", "Test", "The message has one attchament", "c:\winnt\system32\setup.exe"))
End Sub

The samples do the same thing, but the difference between them is that non-blocking mode fires events, and doesn't block your application, and the blocking mode doesn't fire events, and it blocks your application during delivering the message.

NameDescription
errorGets description for an error code.