Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jun 30, 2010 05:12 PM by TGirgenti
Jun 25, 2010 01:28 PM|LINK
Does anybody know if it is possible to download email messages and send something to the email server to delete an email from the server using ASP.NET?
I have developed a program to download email information from my email server, but I can't figure out how to send something to the server to delete an email. I developed what I have using the resources at this location:
I am sick and tired of all the junk mail I am getting and want to write my own program to delete emails from my email server based on criteria I create.
I have VB 3.0, VS 6.0, VS.NET 2003, VS.NET 2005, VS.NET 2008 and VS.NET 2010 Express. I have developed web sites and standalone programs using VB and ASP.NET. My experience and knowledge is not extensive, but i do have enough knowledge to create a VB program.
Any help would be gratefully appreciated.
Jun 25, 2010 05:31 PM|LINK
It says that DELETE commands work as well. Do you know a bit of SQL?
Jun 30, 2010 05:12 PM|LINK
I tried that. I'm getting an error and don't know what to do about it. I don't expect you to know either since it looks like an error specific to IPWorks.
It is blowing up on line 212. Here is the error:
Server Error in '/MailMonitor' Application.
Missing key column [messageid] needed to create command.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: nsoftware.IPWorks.DataProvider.IPWorksException: Missing key column [messageid] needed to create command.
Line 211: ipworksCommand1.CommandText = "DELETE from INBOX WHERE messageid='" + messageIDBoundField + "'"
Line 212: ipworksCommand1.Connection = ipworksConnection1
Line 213: ipworksDataAdapter1.DeleteCommand = ipworksCommand1
Here is the code i use to get the messages:
IPWorksDataSource1.ConnectionString = "protocol=pop; user=" + txtuser.Text + "; password=" + txtPassword.Text + "; mailserver=" + txtMailServer.Text
IPWorksDataSource1.SelectCommandText = "SELECT messageid, messagefrom, messageto, messagesubject, (DateTime)messagedate, messagesize from INBOX"
I have included my code after it has already filled a gridview with the messages from the email server. I'm trying to delete checked messages.
For Each row As GridViewRow In GridView1.Rows
emailIsCheckedBoolean = DirectCast(row.FindControl("chkSelect"), CheckBox).Checked
If emailIsCheckedBoolean Then
Dim ipworksConnection1 As New IPWorksConnection
Dim ipworksDataAdapter1 As New IPWorksDataAdapter
Dim ipworksCommand1 As New IPWorksCommand
ipworksConnection1.ConnectionString = "protocol=pop; user=" + txtuser.Text + "; password=" + txtPassword.Text + "; mailserver=" + txtMailServer.Text
messageIDBoundField = DirectCast(row.FindControl("Label4"), Label).Text
Dim lbl As Label = TryCast(row.FindControl("Label1"), Label)
formattedEmailAddressString = ExtractEmailAddressesFromString(lbl.Text)
ipworksCommand1.CommandText = "DELETE from INBOX WHERE messageid='" + messageIDBoundField + "'"
ipworksCommand1.Connection = ipworksConnection1
ipworksDataAdapter1.DeleteCommand = ipworksCommand1
Thanks for your help.