problem with itemsend

  • Thread starter Thread starter eugenalbiker
  • Start date Start date
E

eugenalbiker

hello everybody,

i have a problem with ms-access when creating a outlook mail vom access
vba code.
Everything is ok, (creating a email, add an attachment and a
recipient).
but when i want to trigger the "myOlApp_ItemSend" the event i only
triggered in my code when the vba-modul use the command ".send".
NOT when the user CLICK send in the email....

here is my code:
----------------------------
' my Class Klasse1
Public WithEvents myOlApp As Outlook.Application

Public Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
MsgBox ("Only test")
End Sub
--------------------------

Dim loOutlook As New Klasse1 'Outlook
Dim loMail As Outlook.MailItem


On Error Resume Next
Set loOutlook.myOlApp = CreateObject("Outlook.Application")
On Error GoTo 0

Set loMail = loOutlook.myOlApp.CreateItem(olMailItem)

' Empfänger eintragen
loMail.To = "(e-mail address removed)"
loMail.Subject = lvSubject
' EMail anzeigen
loMail.Display
' when I use this send command the event "myOlApp_ItemSend" is triggert
ok. But when I delete this and the USER click the "send" button , the
event "myOlApp_ItemSend" is NOT triggered
' lomail.send
-----------------------------------


Any ideas????


greenting
Eugen
 
On 7 Aug 2005 15:56:21 -0700 eugenalbiker wrote:

Hi Eugene,

I suppose your class Klasse1 goes out of scope after the code is executed.

Additionally, if the shown code runs within the class then you´re creating a
second instance of Klasse1 by using Dim...As New, which you have no control
over from outside.
 
Hi Michael,

thanks - problem is solved. The code was running out of klasse1, and
when the procedure exits the var loOutlook is destroyed automatically.
no i dim the procedure with static and the var loOutlook isn't
destroyed when then procedure is ended.

Thanks for the Tip.

Eugen Albiker
 
Back
Top