how to make this code work

P

pierre

In the help they say to paste this code (under the ----) into a class module

Now that it is done:
What is the name of the class i just create? Myolitems?
How can i declare or call it from a regular module
MS say in the help that the code won't work unitl you initialise_handler
How can i do that?

I try

Dim oi as myOlitems
and
oi.initialise_handler from a regular module but it is not working.

Can someone help Me?

Regards, pierre

-----------------------------------------------------------------------
Dim myOlApp As Outlook.Application
Public WithEvents myOlItems As Outlook.Items

Public Sub Initialize_handler()
Set myOlItems =
myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts).Items
End Sub

Private Sub myOlItems_ItemAdd(ByVal Item As Object)
Dim myOlMItem As Outlook.MailItem
Dim myOlAtts As Outlook.Attachments
Set myOlMItem = myOlApp.CreateItem(olMailItem)
myOlMItem.Save
Set myOlAtts = myOlMItem.Attachments
' Add new contact to attachments in mail message
myOlAtts.Add Item, olByValue
myOlMItem.To = "Sales Team"
myOlMItem.Subject = "New contact"
myOlMItem.Send
End Sub

..
 
S

Sue Mosher [MVP-Outlook]

First, are you trying to create VBA code for your own personal use or develop an add-in for other people to use?
What is the name of the class i just create? Myolitems?

It's the name that you gave to the class module.
How can i declare or call it from a regular module

Dim newClassInstance As New said:
MS say in the help that the code won't work unitl you initialise_handler

Call newClassInstance.initialise_handler
 
P

pierre

thanks for the answer,
now i can use it!!
pierre

First, are you trying to create VBA code for your own personal use or develop an add-in for other people to use?




It's the name that you gave to the class module.







Call newClassInstance.initialise_handler
 

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