Opening a Specific Email in GMail Using C# and WatiN - c#

I've been working with sending and receiving email through various web-mail clients using WatiN, I've got logging in, writing and sending emails working perfectly, however I am having issues opening specific emails.
Each email I send has a specific id codein the subject, but I can't work out how to tell WatiN to actually click the specific email. I would of thought it would be something like:
ie.Link(Find.ByText("UN1QU3_1D")).Click();
But due to how Gmail and Live set up their display this doesn't seem to work...
Also, a slightly simpler question, is there a way of preventing WatiN closing the browser once it has finished with it?
Does anyone have any bright ideas?
Many thanks.

Since all gmail message titles are actually in spans not links, I think this will work:
ie.Span(Find.ByText("UN1QU3_1D")).Click();
Also, as far as I remember, WatiN won't close a browser unless you specifically closed them, like:
ie.Close();
UPDATE:
Finally it worked for me :D Span ieFramesSpan = ie.Frames[3].Span( delegate(Span s) { return s.InnerHtml==null? false: s.InnerHtml.Contains("UN1QU3_1D"); }); ieFramesSpan.MouseDown();

Related

Error signing in to gmail this morning

I have a C# app using OpenPop, sending E-Mails through GMAIL.
This app has been working for the last few years, without a problem, and the last EMAIL I got from it was 8 hours ago.
Now I get an 'InvalidLoginException' error when I try to log in. I logged in normally to my account, even tried to change passwords but I still get this same message.
Following previous tips I tried to change the login line from
pop3Client.Authenticate(EMAIL_ADDRESS, ACCOUNT_PASSWORD) to
pop3Client.Authenticate(EMAIL_ADDRESS, ACCOUNT_PASSWORD, AuthenticationMethod.UsernameAndPassword)
But I still get the same message.
Anyone knows what could be wrong?

Connection to Domino crashes

I'm trying to send an email using a Domino server from C#/VB.NET. (Having Lotus Notes client 8.5.3FP6)
The code looks like
using Domino;
...
try
{
NotesSession ns = new NotesSession();
NotesDatabase db = default(NotesDatabase);
NotesDocument doc = default(NotesDocument);
if (ns != null)
{
ns.Initialize(password); // Crashes here
...
I've looked at several example like
http://www.ibm.com/developerworks/lotus/library/domino-msnet/
http://www.codeproject.com/Articles/29442/Send-Lotus-Notes-Email-Using-C
http://www.codeproject.com/Tips/628681/Sending-mail-from-LotusNotes-using-Csharp
Lotus Notes Sending email with options
but they all crash in the Initialize call, without coming to the catch statement so I can see any error message.
What can be wrong? I have tried InitializeUsingNotesUserName as well as not sending in the password to Initialize, with same results.
I've also tried to import the reference to Domino if there was any problem with the interop file.
Thanks!
Try the following setting and see if it helps, can be found in File -> Security - User Security in Notes client
Not sure what your "DB" where you try to create a mail, but when I try to send a mail directly via Lotus Notes I use a selfmade function which directly create the mail into the server based mail.box
The reason why I do that is, that I have seen issues, when multiple users shared the same PC (and where they have only read access to the names.nsf or a local mail.box). I never saw that a client crash, but the issue with missing rights often caused similar error messages (Please not that IBM didn´t really support using the same profile for multiple users, so this is more the users fault because they didn´t the time it takes to relogin via windows). Since using the mail.box I haven´t seen such issues.
I had crashes when calling 'new NotesSession()', and solved it by registering nlsxbe.dll (run as administrator):
> regsvr32 "c:\program files(x86)\ibm\notes\nlsxbe.dll"

Looking for good solutions for blocking TOR

I am running an asp.net mvc website, and i want to block every user that reaches my site through TOR. By now i have two solutions:
Download list of TOR exit nodes once every hour, store that list in
memory, and check every request IP address with that list.
Try to block TOR exit nodes with windows firewall - i think that this would
be better, but i don't know how to do that.
Is there any other possible solution? Have any of you maybe had a similar problem to mine? How did you solve it?
The answer is absolutely the second option you listed. You will have to download a list of known exit node IP's every so often regardless of which solution you use, but using the firewall that already exists is much more simple than rolling your own primitive replica.
How the IP's can be added to the firewall depends on your version of Windows. A previous StackOverflow question whose answer includes links that explain how to programmatically block IP addresses via the Windows Server 2008 firewall can be found here.
Here(https://github.com/RD17/DeTor) is a simple REST API which use TorDNSEl to determine whether a request was made from TOR network or not. I think it will be pretty simple to use it from C# with RESTSharp for example.
The request is:
curl -X GET http://detor.ambar.cloud/.
The response is
{
"sourceIp": "104.200.20.46",
"destIp": "89.207.89.82",
"destPort": "8080",
"found": true
}
As a bonus you can add a badge to your site to detect whether a user comes from TOR or not:
<img src='http://detor.ambar.cloud/badge' />

Get new incoming emails and write their flat file link to a file

I want to get all incoming mails for a certain mailbox and write their Subject , date and flat file link (e.g /-FlatUrlSpace-/5a194b8c1256794581cb898e6b93c34f-112ca9b4/68fcbe48ba7a604086372757c4cea3de-44e6af ) to a file.
How would i go about doing this codewise, i've never worked with the outlook object and know very little about exchange so i'm hoping for some help.
Is there an event for new incoming mails?
Is there a property where i can get the flaturlspace, cause i can't see anything related to it
thx in advance
The way that I've done this in the past is by using WEBDAV. I seem to recall you can request flaturlspace.
Check out this.

Looking for a pop3 reader class in C# with SSL support

I was looking around and there is couple of projects but they all seem to be outdated,
should i use those? or is there a new out the box pop3 class that I can't find in msdn.
anyhow i'm not doing a client that needs to send out so no SMTP is needed, more like a bot that sorts out the emails and reads them., any ideas?
Cheers!
Take a look at Mail.dll POP3 client. It supports SSL, is easy to use, and supports parsing complex MIME structures:
using(Pop3 pop3 = new Pop3())
{
pop3.ConnectSSL("pop3.server.com");
pop3.Login("user", "password");
foreach (string uid in pop3.GetAll())
{
IMail email = new MailBuilder()
.CreateFromEml(pop3.GetMessageByUID(uid));
Console.WriteLine(email.Subject);
}
pop3.Close(true);
}
Please note that this is a commercial product that I developed
You can download Mail.dll here:
http://www.lesnikowski.com/mail/
I discovered OpenPOP on another thread, which seems to be my library of choice at the moment for this very task.
I built one a few years back that's posted on code project and it is dated (http://www.codeproject.com/KB/IP/NetPopMimeClient.aspx). If you are interested I can send you a copy of the latest source code which was never posted to CP.
I ended up using Dart Mail as a replacement for the solution I developed posted on CP. The main reason I ended up using Dart Mail is for the Mime Parsing facilities that it has which really ended up being the main problem with the solution I developed. IIRC Dart Mail is pretty reasonable and may be worth a look if you need something that is robust.

Categories

Resources