View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
E.Anderegg E.Anderegg is offline
external usenet poster
 
Posts: 12
Default how to trap a event coming from a dll

Thanks John, I can enter and write the code for the event-handling
Sorry,but I have not much experience with class modules...
So how can I now access the properties and methods of the DLL??

Ernst

Code so far:

Option Explicit
Dim WithEvents MyMail As vbSendMail.clsSendMail

Private Sub mymail_SendFailed(Explanation As String)
MsgBox "Mail failed with Reason:" & Explanation, vbOKOnly
End Sub

Private Sub mymail_SendSuccesful()
MsgBox "Mail successfil sent", vbOKOnly
End Sub



"John Green" schrieb im Newsbeitrag
...
Ernst,

I'm guessing a bit here, but you should be able to insert a new class

module into your VBA project and enter something like the
following at the top of the module:

Dim WithEvents myMailer as vbSendMail.clsSendMail

You shoud then be able to select the object and its events from the top of

the module and write your event code.

--

John Green - Excel MVP
Sydney
Australia


"E.Anderegg" wrote in message

...
Hello,
I use a mailer DLL in a module.
I set the properties and then kick the Send Method. This works fine so

far.
To check whether a mail was sent correctly, the dll raises the event
SendSuccessful.
How can I trap this event??
Thanks for any help

Ernst


The "simple" code for the problem

Sub SendMails()
Dim Mymailer As Object
Set Mymailer = New vbSendMail.clsSendMail
With ThisWorkbook.Worksheets("Mail")
Mymailer.SMTPHost = .Range("MailSMTPHost").Value
Mymailer.from = .Range("MailFrom").Value
Mymailer.FromDisplayName = .Range("MailfromName").Value
Mymailer.ReplyToAddress = .Range("MailReplyTo").Value
Mymailer.Recipient = .Range("TestMailRecv").Value
Mymailer.Subject = .Range("Testmailbetreff").Value
Mymailer.Message = .Range("Testmailbody").Value
End With
Mymailer.Send

Mymailer.Send
End Sub