where to put to itemsend event and how to use it

  • Thread starter Thread starter Raymond
  • Start date Start date
R

Raymond

Hi

I've created this code that will execute when a bottun on a uferform is
clicked

Private Sub CommandButton1_Click()
Set myOlApp = CreateObject("Outlook.Application")
Set myitem = myOlApp.CreateItem(olMailItem)
myitem.Subject = TextBox1.Text
myitem.To = TextBox2.Text
Filename = TextBox1.Text & Textbox3.text
myitem.saves "c:\temp\" & filename & ".msg" , olmsg
Unload Me
myitem.Display
End Sub

Because the e-mail doesn't heve any message text I don't want to send
it direct.

I know that it's possible to use the event itemsend to do somethings

What I want know is wheren do I have to put the Private Sub
myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
 
The myOlApp_ItemSend procedure would need to go in a class module and the
myOlApp object declared WithEvents and instantiated by some other procedure.

Alternatively, if this is VBA for your own use, you can use the
Application_ItemSend event handler in the built-in ThisOutlookSession
module.
 
Back
Top