Run-Time Error 438 Outlook

  • Thread starter pib311 via AccessMonster.com
  • Start date
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!
 
P

pib311 via AccessMonster.com

Hi Alex,

I created a public function in Outlook called FnSndMail. The code below (when
it works on my main pc) opens outlook, calls the function, and passes
variables to it, then closes Outlook.

The error I have identified happens when I try to call the Outlook function.
It doesn't even start up.

Is there a better way to run a function or procedure in outlook through MS
Access?

Alex said:
Hi,
there is no FnSndMail method of Outlook.Application object. that is why you
are getting this error, no idea why it works on your main PC
here you can find code samples for outlook:
http://www.outlookcode.com/article.aspx?id=44
[quoted text clipped - 64 lines]
 
A

Alex Dybenko

Hi,
if FnSndMail is a public function - then run it as:

blnSuccessful = FnSndMail(strTo, strCC, strBCC, _
strSubject, strMessageBody, strAttachmentPaths)

no need to run it as method of objOutlook object

also not clear - why do initialize variable objOutlook if published proc,
and not in FnSndMail

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com


pib311 via AccessMonster.com said:
Hi Alex,

I created a public function in Outlook called FnSndMail. The code below
(when
it works on my main pc) opens outlook, calls the function, and passes
variables to it, then closes Outlook.

The error I have identified happens when I try to call the Outlook
function.
It doesn't even start up.

Is there a better way to run a function or procedure in outlook through MS
Access?

Alex said:
Hi,
there is no FnSndMail method of Outlook.Application object. that is why
you
are getting this error, no idea why it works on your main PC
here you can find code samples for outlook:
http://www.outlookcode.com/article.aspx?id=44
[quoted text clipped - 64 lines]
 
P

pib311 via AccessMonster.com

Alex,

Thank you for the response. I don't know if I understand your question.

I created a public function within Outlook and am trying to run that function
from MS Access. It's my understanding that i must still call the Outlook
object and then specify the specific function to call. Is that not correct? I
will try your recommendation below to see if that works.

Regards,

Alex said:
Hi,
if FnSndMail is a public function - then run it as:

blnSuccessful = FnSndMail(strTo, strCC, strBCC, _
strSubject, strMessageBody, strAttachmentPaths)

no need to run it as method of objOutlook object

also not clear - why do initialize variable objOutlook if published proc,
and not in FnSndMail
[quoted text clipped - 22 lines]
 
A

Alex Dybenko

Ahh, you have function within Outlook!
Then it makes sense! But then you have to "move" your function to other PC's
Outlook.
Not sure this is a good approach, I would better make all code in Access

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com

pib311 via AccessMonster.com said:
Alex,

Thank you for the response. I don't know if I understand your question.

I created a public function within Outlook and am trying to run that
function
from MS Access. It's my understanding that i must still call the Outlook
object and then specify the specific function to call. Is that not
correct? I
will try your recommendation below to see if that works.

Regards,

Alex said:
Hi,
if FnSndMail is a public function - then run it as:

blnSuccessful = FnSndMail(strTo, strCC, strBCC, _
strSubject, strMessageBody, strAttachmentPaths)

no need to run it as method of objOutlook object

also not clear - why do initialize variable objOutlook if published proc,
and not in FnSndMail
[quoted text clipped - 22 lines]
 

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