P
pib311 via AccessMonster.com
Hello.
I'm trying to run a function out of MS Outlook VBA and having difficulty. On
my main PC it works just fine. On my remote desktop I seem to get the error:
"Run-Time Error: 438. Object doesn't support this property or method".
Again, this is only on my second computer, and I have put the script in both
computer's version of Outlook.
Here is the script:
Public Function SendEmail(strTo As String, _
strSubject As String, _
strMessageBody As String, _
Optional strAttachmentPaths As String, _
Optional strCC As String, _
Optional strBCC As String) As Boolean
Dim objOutlook As Object
Dim objNameSpace As Object
Dim objExplorer As Object
Dim blnSuccessful As Boolean
Dim blnNewInstance As Boolean
'Is an instance of Outlook already open?
On Error Resume Next
Set objOutlook = GetObject(, "Outlook.Application")
On Error GoTo 0
If objOutlook Is Nothing Then
'Outlook isn't already running - create a new instance...
Set objOutlook = CreateObject("Outlook.Application")
blnNewInstance = True
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objExplorer = objOutlook.Explorers.Add(objNameSpace.Folders(1), 0)
objExplorer.CommandBars.FindControl(, 1695).Execute
objExplorer.Close
Set objNameSpace = Nothing
Set objExplorer = Nothing
End If
blnSuccessful = objOutlook.FnSndMail(strTo, strCC, strBCC, _
strSubject, strMessageBody, _
strAttachmentPaths) *****
ISSUE OCCURS HERE*******
If blnNewInstance = True Then objOutlook.Quit
Set objOutlook = Nothing
SendEmail = blnSuccessful
End Function
I can understand if it didn't work on both computures, but I run the same
procedure on both and get different results. Any ideas?
Thanks!
I'm trying to run a function out of MS Outlook VBA and having difficulty. On
my main PC it works just fine. On my remote desktop I seem to get the error:
"Run-Time Error: 438. Object doesn't support this property or method".
Again, this is only on my second computer, and I have put the script in both
computer's version of Outlook.
Here is the script:
Public Function SendEmail(strTo As String, _
strSubject As String, _
strMessageBody As String, _
Optional strAttachmentPaths As String, _
Optional strCC As String, _
Optional strBCC As String) As Boolean
Dim objOutlook As Object
Dim objNameSpace As Object
Dim objExplorer As Object
Dim blnSuccessful As Boolean
Dim blnNewInstance As Boolean
'Is an instance of Outlook already open?
On Error Resume Next
Set objOutlook = GetObject(, "Outlook.Application")
On Error GoTo 0
If objOutlook Is Nothing Then
'Outlook isn't already running - create a new instance...
Set objOutlook = CreateObject("Outlook.Application")
blnNewInstance = True
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objExplorer = objOutlook.Explorers.Add(objNameSpace.Folders(1), 0)
objExplorer.CommandBars.FindControl(, 1695).Execute
objExplorer.Close
Set objNameSpace = Nothing
Set objExplorer = Nothing
End If
blnSuccessful = objOutlook.FnSndMail(strTo, strCC, strBCC, _
strSubject, strMessageBody, _
strAttachmentPaths) *****
ISSUE OCCURS HERE*******
If blnNewInstance = True Then objOutlook.Quit
Set objOutlook = Nothing
SendEmail = blnSuccessful
End Function
I can understand if it didn't work on both computures, but I run the same
procedure on both and get different results. Any ideas?
Thanks!