14-10-21 09:54 AM
Good morning all.
We've run into an issue lately when sending out MI Reports which only happens intermittently, and we're trying to eliminate some of the possibilities that could be causing it. Essentially, an email is generated in the queue during the reporting process, which is sent. However, Outlook is 'killed' once this email is sent, but I'm looking for some way of checking that the Outbox is clear before doing so. I can't seem to find a sufficient action in the VBO (Extended and standard), unless I'm being blind.
Is there a way of checking before closing Outlook that the outbox is clear? Or a slightly more elegant method of closing Outlook other than killing it (assuming that Outlook natively looks to see if it's in the process of sending emails before essentially terminating the process).
Cheers
14-10-21 02:39 PM
Dim app = CreateObject("Outlook.Application")
Dim _nameSpace As Microsoft.Office.Interop.Outlook.NameSpace = app.GetNameSpace("MAPI")
Dim Outlook_Folder_ID as Integer = 4
Dim folder As Folder
If Not String.IsNullOrEmpty(Shared_Mailbox) Then
Dim recipient = _nameSpace.CreateRecipient(Shared_Mailbox)
recipient.Resolve()
If recipient.Resolved Then
folder = _nameSpace.GetSharedDefaultFolder(recipient, Outlook_Folder_ID)
Else
Dim ex1 As New System.Exception(VbCrlf + "Failed to resolve shared mailbox '" + Shared_Mailbox + "'.")
Throw ex1
End If
Else
If Not String.IsNullOrEmpty(Account_Display_Name) Then
Try
Dim aa As List(Of Account) = _nameSpace.Accounts.Cast(Of Account).ToList()
folder = aa.Where(Function(x) x.DisplayName = Account_Display_Name).FirstOrDefault().DeliveryStore.GetDefaultFolder(Outlook_Folder_ID)
Catch ex As System.Exception
Dim ex1 As New System.Exception(VbCrlf + "Failed to retrieve default folder for Account Display Name '" + Account_Display_Name + "'." + VbCrlf + ex.Message)
Throw ex1
End Try
Else
folder = _nameSpace.GetDefaultFolder(Outlook_Folder_ID)
End If
End If
Count = folder.Items.Count
15-10-21 02:27 PM
15-10-21 09:47 PM
27-10-21 05:44 PM
Summary: System upgrades, abrupt Outlook application shutdown, oversized data files are some of the common reasons which may cause Outlook error: “Outlook PST was not cleanly closed by the last program that used it.” And the outcome is that the user is unable to access the Outlook profile in Microsoft Outlook 2019, 2016, 2013, 2010, 2007, 2003 and earlier versions. Here you can find the solution to resolve this error quickly:
For Microsoft Outlook to run uninterruptedly, it is essential to perform proper maintenance and monitor the size of Outlook PST files, because even minor faults may cause an Outlook profile to become inaccessible. And once the user is stuck, there is only one way to resolve the issue – repair the outlook PST file.
The following reasons may cause the error: Outlook PST was not cleanly closed by the last program that used it:
Method 1: Archive, clean or compact large PST data:
Note: Microsoft Outlook runs ‘Sweep Rules’ once in a day, and the ‘Inbox Rules’ are applied as soon as an email arrives in the mailbox.
Method 2: Repair PST by using Scanpst.exe:
Note: Scanpst.exe may result in data loss hence, take a backup of PST file before starting with the manual repair process.
Scanpst.exe may not always be effective in resolving ‘Outlook PST was not cleanly closed by the last program that used it’ error, due to limitations like:
An Outlook Recovery software like Stellar Repair for Outlook can help overcome these shortcomings of scanpst.exe and provide a more efficient solution in case an Outlook PST was not cleanly closed and gets corrupted.
Method 3: Microsoft Outlook Repair Software
Outlook repair software selects the PST file and repairs the corrupt elements. You can save the corrected data as a new PST to reduce further chances of corruption.
_________________________________________
SF Relationship Coaching & Psychotherapy