Deleting emails - WeOnlyDo Discussion board

Deleting emails (General questions)

by Matt, Tuesday, August 29, 2006, 16:17 (6661 days ago)

Hi,

I want to download 'new' emails only and delete emails from the server based on a blacklist

Firstly whats the best way to make sure only new emails are downloaded. I assume this will use a list of UID's previously downloaded but does this mean I have to check every mail header on the server?

Also deleting emails, what if someone had deleted some emails before the prog deletes them. Does it screw up the message numbers. Again do you have to go through each email on the server to find 1 email to delete?

I'm sure someone has a better idea on this. Thanks

Re: Deleting emails

by wodSupport, Tuesday, August 29, 2006, 16:23 (6661 days ago) @ Matt

Matt,

you should check emails based on UID provided by the server, not the headers itself. That's how we do it in SpamBlocker app. If message UID isn't on your list, it is new message then. When you're done, store current message UIDs locally for next session and that's it. Something like this: [code] For i = 0 To Pop3.Messages.Count - 1
If Pop3.Messages(i).Uid = rec.Fields( UID ) Then
found = True
End If
Next i
[/code]. As for 'what if someone else' question - leave this to POP3 server to take care of. Usually he will not allow two sessions to open same inbox at the same time.

Hope this helps.
Kreso

Re: Deleting emails

by Matt, Thursday, August 31, 2006, 13:25 (6659 days ago) @ wodSupport

Brilliant thanks.

BTW I wonder if you know the best way to display HTML emails in VB.NET. If I use a simple textbox, we just get the HTML source.

Re: Deleting emails

by wodDrazen, Thursday, August 31, 2006, 14:14 (6659 days ago) @ Matt

Hi Matt,


You can use Body Property to receive full message body or Text Property to receive message body text, without headers.

Here is example how you can receive full message with Body Property:
---------------------------------------------
For i = 0 To pop3.Messages.Count - 1
TextBox1.Text = TextBox1.Text + pop3.Messages(i).Body
Next i
---------------------------------------------

and for Text Property:
---------------------------------------------
For i = 0 To pop3.Messages.Count - 1
TextBox1.Text = TextBox1.Text + pop3.Messages(i).Text
Next i
---------------------------------------------


Also you can get only parts of that message. Depending how many parts are in the message and what part you want to see.
To get only some part of message we have Parts Property.

Here is example how to get part of Body:
---------------------------------------------
For i = 0 To pop3.Messages.Count - 1
TextBox1.Text = TextBox1.Text + pop3.Messages(i).Parts(1).Body
Next i
---------------------------------------------


or parts from Text:
---------------------------------------------
For i = 0 To pop3.Messages.Count - 1
TextBox1.Text = TextBox1.Text + pop3.Messages(i).Parts(0).Text
Next i
---------------------------------------------


More help for Body Property you can find here:
http://www.weonlydo.com/Pop3/Help/WODPOP3Lib~Pop3Msg~Body.html

More help for Text Property you can find here:
http://www.weonlydo.com/Pop3/Help/WODPOP3Lib~Pop3Msg~Text.html

and for Parts Property here:
http://www.weonlydo.com/Pop3/Help/WODPOP3Lib~Pop3Msg~Parts.html

Hope this helps.


Regards,
Drazen