Does anybody know how to get the following console code to either work with an ASP.Net page, so that I can use labels to display the contents of emails. Or for the following code to output a html/xml page or something which would have hyperlinks on it linking to the e-mails?
I really only want to have the page displaying emails with the following subject titles
Goal, Yellowcard, Redcard.
Thanks
Tom
Imports System
Imports System.IO
Imports Independentsoft.Email
Imports Independentsoft.Email.Mime
Imports Independentsoft.Email.Pop3
Namespace ConsoleApplication1
Class Class1
Shared Sub Main(ByVal args() As String)
Dim client As Pop3Client = New Pop3Client("myPop3Server")
client.Connect()
client.Login("myUsername", "myPassword")
Dim messageInfo() As MessageInfo = client.List()
Dim message() As Message = New Message(messageInfo.Length) {}
Dim i As Integer
For i = 0 To messageInfo.Length - 1 Step i + 1
Dim messageIndex As Integer = messageInfo(i).Index
message(i) = client.GetMessage(messageIndex)
Dim subject As String = message(i).Subject
'Error test on chars
subject = subject.Replace("\", "")
subject = subject.Replace("""", "")
subject = subject.Replace("/", "")
'Error test on Strings
subject = subject.Replace("F" & "U" & "C" & "K", "_")
subject = subject.Replace("G" & "O" & "A" & "L", "Goal")
subject = subject.Replace("R" & "E" & "D" & "C" & "A" & "R" & "D", "Redcard")
subject = subject.Replace("Y" & "E" & "L" & "L" & "O" & "W" & "C" & "A" & "R" & "D", "Yellowcard")
If messageIndex = 1 Then
message(i).Save("c:\email\" & subject & ".eml")
ElseIf messageIndex = 2 Then
message(i).Save("c:\email\" & subject & ".eml")
ElseIf messageIndex = 3 Then
message(i).Save("c:\email\" & subject & ".eml")
ElseIf messageIndex = 4 Then
message(i).Save("c:\email\" & subject & ".eml")
ElseIf messageIndex = 5 Then
message(i).Save("c:\email\" & subject & ".eml")
ElseIf messageIndex = 6 Then
message(i).Save("c:\email\" & subject & ".eml")
ElseIf messageIndex = 7 Then
message(i).Save("c:\email\" & subject & ".eml")
ElseIf messageIndex = 8 Then
message(i).Save("c:\email\" & subject & ".eml")
ElseIf messageIndex = 9 Then
message(i).Save("c:\email\" & subject & ".eml")
End If
Dim allMessages() As String = Directory.GetFiles("c:\email", "*.eml")
Dim messageFile As StreamReader = File.OpenText(allMessages(i))
Dim attachments As AttachmentCollection = message(i).Attachments
Dim attach As Attachment
For Each attach In attachments
attach.Save("c:\attachments")
Next
Next
client.Disconnect()
End Sub
End Class
End Namespace
I really only want to have the page displaying emails with the following subject titles
Goal, Yellowcard, Redcard.
Thanks
Tom
Imports System
Imports System.IO
Imports Independentsoft.Email
Imports Independentsoft.Email.Mime
Imports Independentsoft.Email.Pop3
Namespace ConsoleApplication1
Class Class1
Shared Sub Main(ByVal args() As String)
Dim client As Pop3Client = New Pop3Client("myPop3Server")
client.Connect()
client.Login("myUsername", "myPassword")
Dim messageInfo() As MessageInfo = client.List()
Dim message() As Message = New Message(messageInfo.Length) {}
Dim i As Integer
For i = 0 To messageInfo.Length - 1 Step i + 1
Dim messageIndex As Integer = messageInfo(i).Index
message(i) = client.GetMessage(messageIndex)
Dim subject As String = message(i).Subject
'Error test on chars
subject = subject.Replace("\", "")
subject = subject.Replace("""", "")
subject = subject.Replace("/", "")
'Error test on Strings
subject = subject.Replace("F" & "U" & "C" & "K", "_")
subject = subject.Replace("G" & "O" & "A" & "L", "Goal")
subject = subject.Replace("R" & "E" & "D" & "C" & "A" & "R" & "D", "Redcard")
subject = subject.Replace("Y" & "E" & "L" & "L" & "O" & "W" & "C" & "A" & "R" & "D", "Yellowcard")
If messageIndex = 1 Then
message(i).Save("c:\email\" & subject & ".eml")
ElseIf messageIndex = 2 Then
message(i).Save("c:\email\" & subject & ".eml")
ElseIf messageIndex = 3 Then
message(i).Save("c:\email\" & subject & ".eml")
ElseIf messageIndex = 4 Then
message(i).Save("c:\email\" & subject & ".eml")
ElseIf messageIndex = 5 Then
message(i).Save("c:\email\" & subject & ".eml")
ElseIf messageIndex = 6 Then
message(i).Save("c:\email\" & subject & ".eml")
ElseIf messageIndex = 7 Then
message(i).Save("c:\email\" & subject & ".eml")
ElseIf messageIndex = 8 Then
message(i).Save("c:\email\" & subject & ".eml")
ElseIf messageIndex = 9 Then
message(i).Save("c:\email\" & subject & ".eml")
End If
Dim allMessages() As String = Directory.GetFiles("c:\email", "*.eml")
Dim messageFile As StreamReader = File.OpenText(allMessages(i))
Dim attachments As AttachmentCollection = message(i).Attachments
Dim attach As Attachment
For Each attach In attachments
attach.Save("c:\attachments")
Next
Next
client.Disconnect()
End Sub
End Class
End Namespace