Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-24-2018, 01:43 PM
vodkasoda vodkasoda is offline I am getting an error 91 when trying to delete an E:Mail Windows 7 64bit I am getting an error 91 when trying to delete an E:Mail Office 2007
Novice
I am getting an error 91 when trying to delete an E:Mail
 
Join Date: Apr 2013
Location: Stowmarket, Suffolk, UK
Posts: 15
vodkasoda is on a distinguished road
Default I am getting an error 91 when trying to delete an E:Mail

I have lost some programs so am trying to recreate them from old versions, the problem I have is that I coded this stuff many years ago and can't remember how it all works now, so perhaps one of you can point me in the right direction ...



This is where I decide what type of attachment is coming in so that I can decide what to do with it ...

Code:
NoOfLeagues = NOLindex

Set Ns = GetNamespace("MAPI")
Set Inbox = Ns.GetDefaultFolder(olFolderInbox)
Set SubFolder1 = GetFolder("\\Gary Outlook 2016\Kickabout\Attachments\")
Set SubFolder2 = GetFolder("\\Gary Outlook 2016\Kickabout\Attachments\Unknown")

NoOfEMails = SubFolder1.Items.Count

If NoOfEMails = 0 Then
    Exit Sub
End If

KApath = "K:\"
AtmtNo = 0
ErrorNo = 0
MyKIKtxtCount = 0

For EMailNo = NoOfEMails To 1 Step -1
    Set EMail = SubFolder1.Items(EMailNo)
    KIKcount = 0
    TXTcount = 0
    MySkip = False
    For Each Atmt In EMail.Attachments
        KAfiletype = Right(Atmt.FileName, 3)
        Select Case KAfiletype
            Case Is = "TXT"
                Call Validate_TXT
I then process the TXT file and I want to delete it as I have finished with it, but I am getting this error 91 ...

Code:
Sub Validate_TXT()

Atmt.SaveAsFile KApath & "Despatch Schedule/DESPATCH SCHEDULE.TXT"

Set KA_DB = New ADODB.Connection
Set KA_RS_Leagues = New ADODB.Recordset
Set KA_Com = New ADODB.Command

KA_DB.Open "Provider=SQLOLEDB;Server=GARYSPC\SQLEXPRESS;Database=KADB; Trusted_Connection=yes"

Set KA_Com.ActiveConnection = KA_DB

MyFileNum = FreeFile()
Open KApath & "Despatch Schedule\DESPATCH SCHEDULE.TXT" For Input As #MyFileNum

MyFileNum2 = FreeFile()
Open KApath & "Despatch Schedule\DESPATCH SCHEDULE Edited.TXT" For Output As #MyFileNum2

Do While Not EOF(MyFileNum)
    Input #MyFileNum, MyScheduleData
    DataWanted = False
    Call CheckDSdata
    If DataWanted = True Then
        Print #MyFileNum2, MyScheduleData
    End If
Loop

Close #MyFileNum
Close #MyFileNum2

SubFolder.Items(EMailNo).Delete <<< This fails with Error Code 91, Object variable or With block variable not set.

End Sub
Any help greatly appreciated ...
Reply With Quote
  #2  
Old 01-25-2018, 06:37 AM
vodkasoda vodkasoda is offline I am getting an error 91 when trying to delete an E:Mail Windows 7 64bit I am getting an error 91 when trying to delete an E:Mail Office 2007
Novice
I am getting an error 91 when trying to delete an E:Mail
 
Join Date: Apr 2013
Location: Stowmarket, Suffolk, UK
Posts: 15
vodkasoda is on a distinguished road
Default Stupid mistake

Code:
SubFolder.Items(EMailNo).Delete
should have been

Code:
SubFolder1.Items(EMailNo).Delete
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail System Error - Returned Mail jobeck1 Outlook 0 10-16-2016 08:26 AM
Can't Delete e-mail in outbox EPLenson Outlook 2 05-18-2012 03:14 AM
Google Mail - Can't delete silvercue Outlook 4 01-06-2012 06:10 AM
Can't delete range - error 5904 expatriate Word VBA 1 06-03-2011 12:12 AM
Error: general mail failure. Quit excel restart mail system MitchellDM Outlook 1 12-19-2008 02:05 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:26 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft