G
Gvaram
I want to move MailItems from one folder to another. I know EntryID's of
those mails I want to move and I wrote simple code to do it. But, when
executing Item.Move, error occures - "An unsent message can not be flaged
complete."
Sub aaaaaaaaaaaaaaa()
Dim ns As NameSpace
Dim Archive_0612 As MAPIFolder
Dim FromFolder As MAPIFolder
Dim Item As MailItem
Dim t As Long
Dim DBS As New ADODB.Connection
Dim rst As New ADODB.Recordset
Set ns = GetNamespace("MAPI")
Set FromFolder= ns.Folders.Item("Posloan.Risk")
Set FromFolder= FromFolder.Folders.Item("Inbox")
Set Archive_0612 = ns.Folders.Item("Archive Folders")
Set Archive_0612 = Archive_0612.Folders.Item("Inbox")
With DBS
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0"
.Open "D:\MailID.mdb"
End With
rst.Open "SELECT MailIDs.* FROM MailIDs ORDER BY MailIDs.EntryTime;", DBS,
adOpenKeyset, adLockPessimistic
rst.MoveFirst
For t = 0 To rst.RecordCount - 1
Set Item = ns.GetItemFromID(rst!EntryID, FromFolder.StoreID)
Item.Move Archive_0612 'HERE IS THE PROBLEM......
rst!Done = 1
rst.MoveNext
Next t
rst.Close
DBS.Close
End Sub
Please, someone help me with this...
those mails I want to move and I wrote simple code to do it. But, when
executing Item.Move, error occures - "An unsent message can not be flaged
complete."
Sub aaaaaaaaaaaaaaa()
Dim ns As NameSpace
Dim Archive_0612 As MAPIFolder
Dim FromFolder As MAPIFolder
Dim Item As MailItem
Dim t As Long
Dim DBS As New ADODB.Connection
Dim rst As New ADODB.Recordset
Set ns = GetNamespace("MAPI")
Set FromFolder= ns.Folders.Item("Posloan.Risk")
Set FromFolder= FromFolder.Folders.Item("Inbox")
Set Archive_0612 = ns.Folders.Item("Archive Folders")
Set Archive_0612 = Archive_0612.Folders.Item("Inbox")
With DBS
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0"
.Open "D:\MailID.mdb"
End With
rst.Open "SELECT MailIDs.* FROM MailIDs ORDER BY MailIDs.EntryTime;", DBS,
adOpenKeyset, adLockPessimistic
rst.MoveFirst
For t = 0 To rst.RecordCount - 1
Set Item = ns.GetItemFromID(rst!EntryID, FromFolder.StoreID)
Item.Move Archive_0612 'HERE IS THE PROBLEM......
rst!Done = 1
rst.MoveNext
Next t
rst.Close
DBS.Close
End Sub
Please, someone help me with this...