Access/Outlook

mdmilner

Well-known Member
Joined
Apr 30, 2003
Messages
1,352
I'm trying to hunt down a problem. This isn't the entire function but it's the meat of it to send an email. This worked well under A2K and Win2K - but now on a WinXP install it's dying with the message:

Error 429: ActiveX Component can't create object right where it's attempting to create Outlook.Application.

Only real difference I see is the Outlook 9.0 Object library isn't loaded - just the Outlook 11.0 Object library (in the references)...and I'm wondering if that might be part of the problem.

Really, I'm just beginning to troubleshoot this.

Mike

Code:
Public Function sendMail(ByVal Recipient As String, _
                         ByVal Subject As String, _
                         ByVal Message As String, _
                         Optional ByVal AttachmentPath As String)
'Dim objOutlook As Outlook.Application
'Dim objOutlookMsg As Outlook.MailItem
'Dim objOutlookAttach As Outlook.Attachment
'Dim objOutlook As Object
Dim objOutlook As Object
Dim objOutlookMsg As Object
Dim objOutlookAttach As Object

'Dim MessageHeader

On Error GoTo HandleErr

Set objOutlook = CreateObject("Outlook.Application")

' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
   .To = Recipient
   .Subject = Subject
   .Body = Message
   .Importance = olImportanceNormal 'Selects importance

   If Not IsMissing(AttachmentPath) Then
      Set objOutlookAttach = .Attachments.Add(AttachmentPath)
   End If
End With

objOutlookMsg.Send
End Function
 

Some videos you may like

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

mdmilner

Well-known Member
Joined
Apr 30, 2003
Messages
1,352
Hmmm, it always seems like as soon as I post I figure it out.
I think this is because I'm confusing Access. I've loaded up the reference and then attempted to use late binding.

Hmmm - I'm at a loss as to why late binding isn't working properly. I'd have thought it would have been the failsafe. My current work-around is to use early-binding.

Looks like I've got to start digging around on this NEW machine a bit more. The last Office install I did personally - so I knew every component that was on it. This one was a 'company standard' install and I'm thinking something is not quite correct. I'm sure I'll have to figure it out eventually.

If anybody has any guesses/hints, I'd really appreciate a tip on what to try to look for.

Mike
 

Watch MrExcel Video

Forum statistics

Threads
1,118,071
Messages
5,570,023
Members
412,304
Latest member
citrus
Top