Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime error 2113732605 1

Status
Not open for further replies.

jonney

Instructor
Jun 17, 2003
35
GB
I have a bit of code creating a an email message with a couple of attachments from an access 97 db. It has been working OK. Now the runtime error mentioned appears at the following line:
Set objEmail = objOutlook.CreateItem(olMailItem)line.
I have enclosed the code below. Any ideas?

Private Sub cmdSend_Click()
Dim Email As String

'**create variables for Outlook
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Dim Attachments As Attachment
'**gathers information from your form. this sets the string variable to your fields
Email = Me!Email

'***creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

'MsgBox (docpath & Forms![frmProdSpecsDistribution]![frmProdSpecsDistributionNew].Form![DocumentCL]
'***creates and sends email
With objEmail
.To = Email
If Not IsNull([CL]) Then
.Attachments.Add (docpath & Forms![frmProdSpecsDistribution]![frmProdSpecsDistributionNew].Form![CL] & ".doc ") 'add attachment"
'MsgBox Forms![frmProdSpecsDistribution]![frmProdSpecsDistributionNew].Form![CLpdf]
.Attachments.Add (docpathpdf & Forms![frmProdSpecsDistribution]![frmProdSpecsDistributionNew].Form![CLpdf]) 'add attachment"
End If
If Not IsNull([LI]) Then
.Attachments.Add (docpath & Forms![frmProdSpecsDistribution]![frmProdSpecsDistributionNew].Form![LI] & ".doc ") 'add attachment"
End If
If Not IsNull([PI]) Then
.Attachments.Add (docpath & Forms![frmProdSpecsDistribution]![frmProdSpecsDistributionNew].Form![PI] & ".doc ") 'add attachment"
.Attachments.Add (docpathpdf & Forms![frmProdSpecsDistribution]![frmProdSpecsDistributionNew].Form![PIpdf]) 'add attachment"
End If
If Not IsNull([BOT]) Then
.Attachments.Add (docpath & Forms![frmProdSpecsDistribution]![frmProdSpecsDistributionNew].Form![BOT] & ".doc ") 'add attachment"
'MsgBox Forms![frmProdSpecsDistribution]![frmProdSpecsDistributionNew].Form![BOTpdf]
.Attachments.Add (docpathpdf & Forms![frmProdSpecsDistribution]![frmProdSpecsDistributionNew].Form![BOTpdf])
End If
If Not IsNull([FIT]) Then
.Attachments.Add (docpath & Forms![frmProdSpecsDistribution]![frmProdSpecsDistributionNew].Form![FIT] & ".doc ") 'add attachment"
.Attachments.Add (docpathpdf & Forms![frmProdSpecsDistribution]![frmProdSpecsDistributionNew].Form![FITpdf])
End If
.Display
End With

'**closes outlook
'objOutlook.Quit
Set objEmail = Nothing

Exit Sub

End Sub
 
I've had this problem quite a while ago and remember clearing it up using the Logon method of the NameSpace object. I can't remember exactly the parameters I used for the Logon method but you might try adding the blue into your code:

Code:
Dim objOutlook As Outlook.Application
[blue][b]Dim objNameSpace as Outlook.NameSpace[/b][/blue]
Dim objEmail As Outlook.MailItem
. . .
Set objOutlook = CreateObject("Outlook.application")
[blue][b]Set objNameSpace = objOutlook.GetNamespace("MAPI")
objNameSpace.Logon ...[/b][/blue]

Hope this gets you going in the right direction,

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top