Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What references do I need to automate outlook?

Status
Not open for further replies.

qjd2004

Technical User
Feb 2, 2004
80
GB
Hiya,

trying to send an email through outlook from excel.

The excel VBA compiler says that the Active X component can't create the object, which I beleive is because I'm not refering to the correct component in my project settings. Thing is, I can't see any outlook references that aren't already ticked.

Problem occurs when Initialising the second of these 2 variables:
Code:
Set objOutlook = New Outlook.Application
Set olMail = New Outlook.MailItem

Can anyone help out me on this one?
 
Try something like:
Code:
Dim objOutlook As Outlook.Application
    Dim olMail As Outlook.MailItem
    
    Set objOutlook = New Outlook.Application
    Set olMail = objOutlook.CreateItem(olMailItem)

HTH
 
Hiya,

this still doesn't work and I've referenced the Outlook 98 Type Library as well. It says activex component cannot create object. I cannot see what's wrong with it!

Code:
Dim objApp
Set objApp = CreateObject("Outlook.Application")
Dim email As String
Dim zu as string
Dim myMailItem As New Outlook.MailItem
email = "me@myaddress.com"
zu = "Whatever"

With myMailItem
  .To = email  'this is where the Item has been moved or deleted error
  .Display
  .Subject = "Automatic Notification."
  .Body = "FYI:   " & sys_date & _
            vbCrLf & "File(s) received from " & _
                zu & "!" & vbCrLf & vbCrLf & _
                "Notification will be sent once processing is complete." & _
                vbCrLf & vbCrLf & "Kind Regards," & vbCrLf & "Me"
  .Send
  
End With

End Sub

Can anyone tell me why this won't work?

 
This works for me (setting ref to Outlook 10.0):
Code:
    Dim objApp
    Dim mi As Outlook.MailItem
    Set objApp = CreateObject("Outlook.Application")
    
    Set mi = objApp.CreateItem(olMailItem)

I don't see the CreateItem in your code?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top