Outlook mail item A2K vs A2K3

supmktg

Registered User.
Local time
Today, 15:22
Joined
Mar 25, 2002
Messages
360
The following code works perfectly in A2k, but gives a -2147024770 error in A2k3 on my client's workstation:
Code:
Sub CreateMailItem(strRecip As String, strHome As String, strAttach1 As String, Optional strAttach2 As String, Optional strAttach3 As String)

'make a reference to Microsoft outlook 9.0 library
Dim objolk As Outlook.Application
Dim objMailItem As Outlook.MailItem
Dim olkNameSpace

  On Error GoTo CreateMailItem_Error

Set objolk = New Outlook.Application

Set olkNameSpace = objolk.getNameSpace("MAPI")

Set objMailItem = objolk.CreateItem(olMailItem)

 objMailItem.To = strRecip
 objMailItem.Subject = strHome & " Forms"
 objMailItem.body = "Attached are Encounter Forms"
 objMailItem.attachments.Add strAttach1
 objMailItem.attachments.Add strAttach2
 objMailItem.attachments.Add strAttach3
 objMailItem.Display
 'objMailItem.Send
 Set objMailItem = Nothing
 Set objolk = Nothing

   On Error GoTo 0
   Exit Sub

CreateMailItem_Error:

    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure CreateMailItem of VBA Document Form_frmAdminContacts"

 End Sub

Do I need a reference set to a newer outlook library? If so, how can I do that if I don't have A2k3 installed?

Thanks,
Sup
 
still need Outlook automation help?

All of the research that I've done indicates that a reference to the Microsoft outlook 9.0 library should work in Access 2003 (with outlook 11.0). Also, the code works fine in Access XP (with outlook 10.0), so I don't think the wrong reference is my problem.

Has anyone run into this problem?

Thanks,
Sup
 
I've now tested the code on a different workstation using Access/Outlook 2003 and it works! There must be something specific to his installation that is causing the problem. Where can I look? How can I isolate the problem? Can someone point me in the direction of a different email w/attachments method that might work?

Can anybody help me, please?

Thanks,

Sup
 

Users who are viewing this thread

Back
Top Bottom