S
Scruffy McScruffovitch
Greetings everyone.
I need a correction to my code, I think.
Up until now, we have been working with Office 2003, Windows XP Pro, and
Novell as our network client. We've been using Groupwise 6 for e-mail.
I just got the word that over the summer, we will be dumping Novell, and
Groupwise, upgrading to Office 2007 and Outlook 2007.
Bastards, another couple of years and I would have retired secure in the
knowledge that I don't have to learn new crap. Oh well.
Since I am not going to get that luxury, I have downloaded the 60 day demo
version of Office 2007 and have been pretty successful at finding and
learning the new features, althought he "Ribbon Technology" seems like a
step backwards to me. I have one problem with code that I am using to send
e-mail from Access 2007, through Outlook 2007.
The code is:
__________________________________________________________________________________________________
Option Compare Database
Option Explicit
Public Function SendMail(DisplayMsg As Boolean, strTo As String, strCC As
String, strBCC As String, _
strSubject As String, strBody As String, strAttachPathFile As String) As
Boolean
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Set objOutlook = CreateObject("Outlook Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
'Add "To" recipient
Set objOutlookRecip = .Recipients.Add(strTo)
objOutlookRecip.Type = olTo
'"Add "CC" recipient
If IsNull(strCC) = False Then
Set objOutlookRecip = .Recipients.Add(strCC)
objOutlookRecip.Type = olCC
End If
'Add "BCC" recipient
If IsNull(strBCC) = False Then
Set objOutlookRecip = .Recipients.Add(strBCC)
objOutlookRecip.Type = olBCC
End If
'Add subject, body, and importance of the E-Mail Messzage
.Subject = strSubject
.Body = strBody
.Importance = olImportanceHigh
'Add Attachment
If IsNull(strAttachPathFile) = False Then
Set objOutlookAttach = .Attachments.Add(strAttachPathFile)
End If
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next objOutlookRecip
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Function
______________________________________________________________________________________________________
When I try to run this code, it gives me an error "429", "Active X Component
Can Not Create Object", at the line:
"Set objOutlook = CreateObject("Outlook Application")"
All help will be greatly appreciated. Thanks!
I need a correction to my code, I think.
Up until now, we have been working with Office 2003, Windows XP Pro, and
Novell as our network client. We've been using Groupwise 6 for e-mail.
I just got the word that over the summer, we will be dumping Novell, and
Groupwise, upgrading to Office 2007 and Outlook 2007.
Bastards, another couple of years and I would have retired secure in the
knowledge that I don't have to learn new crap. Oh well.
Since I am not going to get that luxury, I have downloaded the 60 day demo
version of Office 2007 and have been pretty successful at finding and
learning the new features, althought he "Ribbon Technology" seems like a
step backwards to me. I have one problem with code that I am using to send
e-mail from Access 2007, through Outlook 2007.
The code is:
__________________________________________________________________________________________________
Option Compare Database
Option Explicit
Public Function SendMail(DisplayMsg As Boolean, strTo As String, strCC As
String, strBCC As String, _
strSubject As String, strBody As String, strAttachPathFile As String) As
Boolean
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Set objOutlook = CreateObject("Outlook Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
'Add "To" recipient
Set objOutlookRecip = .Recipients.Add(strTo)
objOutlookRecip.Type = olTo
'"Add "CC" recipient
If IsNull(strCC) = False Then
Set objOutlookRecip = .Recipients.Add(strCC)
objOutlookRecip.Type = olCC
End If
'Add "BCC" recipient
If IsNull(strBCC) = False Then
Set objOutlookRecip = .Recipients.Add(strBCC)
objOutlookRecip.Type = olBCC
End If
'Add subject, body, and importance of the E-Mail Messzage
.Subject = strSubject
.Body = strBody
.Importance = olImportanceHigh
'Add Attachment
If IsNull(strAttachPathFile) = False Then
Set objOutlookAttach = .Attachments.Add(strAttachPathFile)
End If
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next objOutlookRecip
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Function
______________________________________________________________________________________________________
When I try to run this code, it gives me an error "429", "Active X Component
Can Not Create Object", at the line:
"Set objOutlook = CreateObject("Outlook Application")"
All help will be greatly appreciated. Thanks!