Help with deleting mails in notes.

747

New Member
Joined
Mar 9, 2004
Messages
5
Hi please help a first timer.

I am trying to delete mails after extracting the data that I need.
Can't seem to do it without going into a loop.
This is the working code without the deleting bit.
Private Sub notplannedmails()
Dim session As Object
Dim db As Object
Dim dc As Object
Dim doc As Object
Dim str As String
Dim workspace As NOTESUIWORKSPACE
Set session = CreateObject("notes.notessession")
Dim uidoc As NOTESUIDOCUMENT :rolleyes:

Set db = session.GETDATABASE("****", "****")
'Searching for the line
Set dc = db.FTSEARCH("""Not Planned consignments on Flight""", 50)
Set doc = dc.GETFIRSTDOCUMENT

counter = 0
While Not (doc Is Nothing)
counter = counter + 1
Dim msg, frm As String
Dim rcvdt As Variant
msg = doc.Body
Sheets("Sheet1").Select
Cells(1, 1).Select
On Error Resume Next
Wait "0.3"
ActiveCell.Value = msg
flt = Cells(1, 1).Value
flt = Mid(flt, 11, 6)
Cells(2, 1).Value = flt
awbs = Cells(1, 1).Value
cntr = 0
startpoint = InStr(awbs, "AWB")
For red = 1 To 10
If startpoint = 0 Then Exit For
cntr = cntr + 1
startpoint = InStr(startpoint + 4, awbs, "AWB")
Next
Sheets("Not Planned Emails").Select
Cells(179, 1).Select
Selection.End(xlUp).Select
Selection.Offset(1, 0).Select
Selection.Value = flt
Selection.Offset(0, 1).Value = cntr

cntr = 0
flt = ""
msg = ""
Sheets("Sheet1").Select
Cells(1, 1).ClearContents
Cells(2, 1).ClearContents
Sheets("Not Planned Emails").Select
Wait "0.3"
Set doc = dc.GETNEXTDOCUMENT(doc)
Wait "0.3"
Call workspace.VIEWREFRESH
Wend

'Call dc.Remove(True) (This bit is not working)

Wait "0.3"

MsgBox counter & " Flights entered."
End Sub
 

Some videos you may like

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Watch MrExcel Video

Forum statistics

Threads
1,123,259
Messages
5,600,572
Members
414,389
Latest member
MarkElla

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top