| | #1 |
| Senior Warrior Member War Room Member Join Date: 2010
Posts: 1,596
Thanks: 276
Thanked 515 Times in 263 Posts
|
Hi, Anyone know the code or how to parse through emails that a site gives you and click the links inside of them. Im using the dll OpenPop3 but so far have only figured out how to login. Any help would be appreciated |
| | |
| |
| | #2 |
| HyperActive Warrior Join Date: 2011 Location: Edmonton, Alberta
Posts: 120
Thanks: 0
Thanked 25 Times in 23 Posts
|
Just download the emails with the POP3 connection, then you can use the following regex to match all the links. #(http|https|ftp)://([A-Z0-9][A-Z0-9_-]*(?:.[A-Z0-9][A-Z0-9_-]*)+):?(d+)?/?#i |
| |
| | #3 |
| Senior Warrior Member War Room Member Join Date: 2010
Posts: 1,596
Thanks: 276
Thanked 515 Times in 263 Posts
|
Can I use OpenPop3 or do I use the built in support for POP3 that C# brings?
|
| |
| | #4 |
| HyperActive Warrior Join Date: 2011 Location: Edmonton, Alberta
Posts: 120
Thanks: 0
Thanked 25 Times in 23 Posts
|
I checked out OpenPop3 on SourceForge but I don't see any files or examples so I can't tell you for sure. I imagine its just a helper library to communicate with the built in POP3 functions so I don't see why not, try reading the documentation. Also, I found another similar library called OpenPop OpenPop.NET | Free Communications software downloads at SourceForge.net which seems to actually have files to download and it says it supports all the common POP3 functions and email MIME types. |
| |
| | #5 |
| Senior Warrior Member War Room Member Join Date: 2010
Posts: 1,596
Thanks: 276
Thanked 515 Times in 263 Posts
|
This is what I have so far: Code: Pop3Client client = new Pop3Client();
client.Connect("pop3.live.com", 995, true);
client.Authenticate("USER", "PASSWORD");
label18.Text = client.GetMessageCount().ToString();
int messageCount = client.GetMessageCount();
for (int i = 1; i <= messageCount; i++)
{
// Download the header and check if the message is interesting
// enough to download if with body
MessageHeader header = client.GetMessageHeaders(i);
if ("Wordpress".Contains(header.Subject))
{
// The message is interesting - download it
OpenPop.Mime.Message message = client.GetMessage(i);
// Find the first part containing HTML
// null is returned if such part is not found
MessagePart html = message.FindFirstHtmlVersion();
if (html != null)
{
String htmlContained = html.GetBodyAsText();
// Do something with the html
// here showing it in a listbox
richTextBox1.Text = htmlContained;
}
}
}
client.Disconnect(); |
| |
| | #6 |
| HyperActive Warrior Join Date: 2011 Location: West Palm Beach, FL
Posts: 113
Thanks: 7
Thanked 12 Times in 11 Posts
|
You could looks for the characters "<a href", then split the strings up til you find the immediate next "</a>". Then add all those split strings into a generic list. Once they're in a generic list you can bind that list to a repeater, and dynamically create them as a page you could click the links on. Here's some info on generic lists: An Introduction to C# Generics |
| | |
| |
| | #7 |
| Software/Database Expert War Room Member Join Date: 2011 Location: Austin, TX
Posts: 75
Thanks: 47
Thanked 24 Times in 21 Posts
|
I know it looks like a bunch of gobbleygook, but you should really use the Regular Expression method that unnatural posted. C# has a great Regular Expression library and there is tons of free sample code out there. You can literally parse ALL LINKS out of an email in 3-4 lines of code. gtownfunk |
| |
|
| Bookmarks |
| Tags |
| c sharp, email, emails, openpop, parse |
| |