UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Run-time Error When Launching Microsoft Outlook 2010, Access 2010    
 
   
graeme_706
post Aug 22 2019, 05:03 PM
Post#1



Posts: 76
Joined: 3-August 10
From: Scotland, UK


Hi,

I'm taking a report and generating a pdf then sending as an attachment using Microsoft Outlook 2010.

When I run this sequence, it may work 15 times, then it will fail. Error Run-time error '-2147467259 (8000-4005)' The operation failed. The messaging interfaces have returned an unknown error. If the problem persists, restart Outlook

I'm using windows 10, Access 2010 and Microsoft outlook 2010

My recovery from the error is to either force a shutdown on Microsoft Outlook (task manager / End Task) or to reboot the PC

Anyone seen this before ? Any clues how to fix ?


Here is my code :-

Private Sub Label42_Click()
Dim bcRet As Boolean
"C:\MyPDF\Invoice.pdf", False, False, 150, "", "", 0, 0, 0)
"C:\MyPDF\Breakdown.pdf", False, False, 150, "", "", 0, 0, 0)
"C:\MyPDF\Invoice.pdf", False, False, 150, "", "", 0, 0, 0)
Dim Inv4wName As String
Dim finv4Name As String
Inv4wName = Me.lstRptInv4w
finv4Name = "C:\MyPDF\Invoice_P" & Text140.Value & "_" & Text51.Value & ".pdf"
DoCmd.OpenReport Inv4wName, acViewPreview
DoCmd.OutputTo acOutputReport, Inv4wName, acFormatPDF, finv4Name
DoCmd.Close acReport, Inv4wName, acSaveNo
Dim reportName4 As String
Dim fileName4 As String
reportName4 = Me.lstRptBdown4w
fileName4 = "C:\MyPDF\Breakdown_P" & Text140.Value & "_" & Text51.Value & ".pdf"
DoCmd.OpenReport reportName4, acViewPreview
DoCmd.OutputTo acOutputReport, reportName4, acFormatPDF, fileName4
DoCmd.Close acReport, reportName4, acSaveNo
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
If olApp Is Nothing Then
Set olApp = CreateObject("Outlook.Application")
If olApp Is Nothing Then
MsgBox "Can't start Outlook", vbExclamation
Exit Sub
End If
End If
On Error GoTo 0
Dim objMail As Outlook.MailItem
Dim objAttach As Outlook.Attachments
Set objMail = olApp.CreateItem(olMailItem)
objMail.To = Combo7.Column(1)
objMail.Subject = "Invoice for " & Combo7.Column(3)
objMail.Body = "Hi " & Combo7.Column(2) & "," & Chr$(13) & Chr$(13) & "Please find attached Invoice " & Chr$(13) & Chr$(13) & "Thanks,"
Set objAttach = objMail.Attachments
objAttach.Add "C:\MyPDF\Breakdown_P" & Text140.Value & "_" & Text51.Value & ".pdf"
objAttach.Add "C:\MyPDF\Invoice_P" & Text140.Value & "_" & Text51.Value & ".pdf"
objMail.Display
End Sub


Graeme
This post has been edited by graeme_706: Aug 22 2019, 05:27 PM
Go to the top of the page
 
theDBguy
post Aug 22 2019, 05:10 PM
Post#2


Access Wiki and Forums Moderator
Posts: 76,288
Joined: 19-June 07
From: SunnySandyEggo


Hi. Unless I missed it, you don't seem to be clearing your object variables, so you may be running out of memory.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
graeme_706
post Aug 22 2019, 05:33 PM
Post#3



Posts: 76
Joined: 3-August 10
From: Scotland, UK


Hi,

I'm self taught on Access, could I get some guidance on how I should clear the object variables ?

Kind regards,

Graeme

Go to the top of the page
 
MadPiet
post Aug 22 2019, 05:53 PM
Post#4



Posts: 3,279
Joined: 27-February 09



all the object variables (the ones you used Set with), like objOutlook etc

once you're done using them, you clean up:

set rs = Nothing
set objOutlook = Nothing

etc.

Otherwise, the objects remain in memory the whole time...
Go to the top of the page
 
graeme_706
post Aug 23 2019, 12:30 PM
Post#5



Posts: 76
Joined: 3-August 10
From: Scotland, UK


Thanks Madpiet, I'll give it a try
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    15th September 2019 - 02:59 AM