where to put to itemsend event and how to use it

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)
 
S

Sue Mosher [MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top