Author |
|
Guests Guest Group
Joined: 10 November 2003
Online Status: Online Posts: 262
|
Posted: 29 June 2005 at 6:49am | IP Logged
|
|
|
Hi have just purchased MailBee Objects and have the following problem.
I retrieve the headers with Pop.RetrieveHeaders(0)
I then examine each header in turn to see if it is a message I wish to process. If so i then want to delete the message from the server.
In order to delete a message i need an ID so i tried this :
Dim Index as Long
Index = POP.GetMessageNumberFromUID(Msg.MessageId)
POP.DeleteMessage Index
However the GetMessageNumberFromUID call always fails with error 203 - [Error: UID value not found]
|
Back to Top |
|
|
Guests Guest Group
Joined: 10 November 2003
Online Status: Online Posts: 262
|
Posted: 29 June 2005 at 7:03am | IP Logged
|
|
|
After reading other posts on this topic I thought i should mention that
1) the app is connected to the server during the call to GetMessageNumberFromUID
2) the MessageID originally had the value enclosed in <> brackets. I remove them before the call to GetMessageNumberFromUID but it still fails.
3) the message in question is still on the server.
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 29 June 2005 at 7:35am | IP Logged
|
|
|
UID (Unique-ID) and Message-ID are completely different things.
UID is somewhat like message number but it's always unique: no two messages can have the same UID in the same mailbox. UID is assigned by the mail server when the message arrives into the mailbox. If the same message is placed into the mailbox again, it will have different UID.
On other hand, Message-ID is a value of Message-ID header of the message itself. If the same message is placed into the mailbox twice, both copies will have the same Message-ID. The message may even have no Message-ID at all. Thus, Message-ID cannot be converted into message number. You should delete messages directly by their message numbers.
In your case, you can get message number of the particular message and delete it using the code like below:
Code:
' For simplicity, I use no error checking and assume
' all the methods succeed
Set Msgs = POP3.RetrieveHeaders
For I = 1 To Msgs.Count
If Msgs(I).Subject = "Delete me" Then
POP3.DeleteMessage I
End If
Next
|
|
|
Regards,
Alex
|
Back to Top |
|
|
Guests Guest Group
Joined: 10 November 2003
Online Status: Online Posts: 262
|
Posted: 29 June 2005 at 8:42am | IP Logged
|
|
|
Alex,
i appreciate the time you have taken to answer. The problem is I want to be able to retrieve all the headers, then go offline. At some point later I wish to go online again and delete certain messages.
I do not think I can use the for i = 1 to msgs.count loop as the message indexes may have changed between logins ?
|
Back to Top |
|
|
Guests Guest Group
Joined: 10 November 2003
Online Status: Online Posts: 262
|
Posted: 29 June 2005 at 8:46am | IP Logged
|
|
|
Alex,
I may have a solution. When i retrieve the headers I then iterate through the collection and store away their UID's with :
UID(arrIndex) = m_POP.GetMessageUID(Index)
I can there go back online later and use the following:
Index = m_POP.GetMessageNumberFromUID(UID(arrIndex))
m_Pop.Deletemessage Index
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 29 June 2005 at 9:03am | IP Logged
|
|
|
Yes, this will work. You can even optimize this and call POP3.Search to get array of UIDs for all messages at once instead of getting individual UIDs with POP3.GetMessageUID.
Set Msgs = POP3.RetrieveHeaders(0)
UIDs = POP3.Search
UIDs array can then be accessed like this:
For I = 1 To UBound(UIDs)
MsgBox UIDs(I) ' Display UID for I-th message
Next
Regards,
Alex
|
Back to Top |
|
|
Guests Guest Group
Joined: 10 November 2003
Online Status: Online Posts: 262
|
Posted: 29 June 2005 at 10:39am | IP Logged
|
|
|
Excellent, thank you for that optimization Alex.
By the way this is an excellent product - i will have no hesitation recommending it to people.
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 29 June 2005 at 11:03am | IP Logged
|
|
|
Many thanks for your appreciation!
Regards,
Alex
|
Back to Top |
|
|