Creates and initializes a licensed Message object at runtime.
Type | Description | |||
Message | A Message object being created. |
Use the NewMessage property to create licensed Message objects at runtime. Applications that use CreateObject or the New operator to instantiate Message objects will not run on machines where ExEMail is not licensed. To ensure proper functionality and generate licensed objects at runtime, always use the NewEMail and NewMessage properties.
In isolated applications, however, the NewEmail and NewMessage properties cannot be used. In this case, you must instantiate the objects directly using their CLSIDs:
The following VB6 example shows how to implement a CreateFromCLSID function that uses Windows API calls (CLSIDFromString and CoCreateInstance) to create COM objects by CLSID:
Private Declare Function CLSIDFromString Lib "ole32" (ByVal s As Long, ByRef id As Any) As Long Private Declare Function CoCreateInstance Lib "ole32" (ByRef clsid As Any, ByVal pUnk As Long, ByVal ctx As Long, ByRef iid As Any, ByRef obj As Any) As Long Public Function CreateFromCLSID(s As String) As Object Dim c(15), i(15), o As Object CLSIDFromString StrPtr(s), c(0) CLSIDFromString StrPtr("{00000000-0000-0000-C000-000000000046}"), i(0) ' IID_IUnknown If CoCreateInstance(c(0), 0, 1, i(0), o) = 0 Then Set CreateFromCLSID = o
The following sample shows how to send an email using blocking mode:
Private Sub Form_Load() Dim m As Message Set m = Runtime1.NewMessage If (0 = m.Send("me", "mike1@Unknown2.com,mike2@Unknown2.com,mike3@Unknown2.com", "Hello")) Then MsgBox "The message was delivered OK." End If End Sub
The following sample shows how to send an email using non-blocking way:
Dim WithEvents e As EMail Private Sub e_EndSend(ByVal Msg As EXEMAILLibCtl.IMessage) If (Msg.LastError = 0) Then MsgBox "The message was delivered OK." End If Debug.Print e.Error(Msg.LastError) End Sub Private Sub Form_Load() Set e = Runtime1.NewEMail Dim m As Message Set m = Runtime1.NewMessage Set m.Notifier = e m.Send "me", "mike1@Unknown2.com,mike2@Unknown2.com,mike3@Unknown2.com", "Hello" End Sub