Programmatically Verify an email message reached an exchange mail box - c#

I have a job that runs which sends out emails to our users to which starts off a work flow process in our company. Periodically, a user will swear up and down that they didn't receive the email - though, when we go to the mail administrator to pull an exchange report, 10 times out of 10 it's in their deleted items. :P
I'd like to be able to programmatically verify that messages sent via .net C# (System.Net.Mail I think) reached the user's mail box.
It's exchange 2007 and all messages are internal.

You can't with System.Net.Mail. You'll have to dig through Exchange's APIs to determine if an email is present in someone's email account.
http://support.microsoft.com/kb/813349

Set an account for catching all bounce backs. In this way you will know which ones reached and which ones did not. This is the best way to ensure emails reached.
Alternatively you can add read reciepts via message headers(by setting the Disposition-Notification-To). but again, user can chose not to read it...

I see two ways to do what you want:
Send emails with "delivery confirmation" On (not "read receipt", this can be dismissed by the user as CoddeToGlory said). Then it's jut a matter of monitoring the mailbox that receives these confirmations via any way it's appropiate to you: Exchange Web Services, Outlook+COM or VBA, MAPI, ...
Use the powershell interface to Exchange and capture the output of Get-MessageTrackingLog looking for StoreDriver + Deliver events.

Related

Email push notification for new message in c#

I am using IBM lotus note web mail server and looking for a solution on this diagram. My program is written in C# language with OpenPop.NET. Is there an efficient way to monitor new email received in inbox instead of running a schedule job every 1 minute like new mail notification or some signalR type of? I believe that connecting to web mail box again and again every 1 minute is not a good practice. Please suggest.
To the best of my knowledge, there is no published API for push notifications of message delivery from the IBM Domino server.
assuming you can modify the design of the mail files, you could write "before/after new mail arrives" Notes agents. That could send out the notifications, deposit the info in another db, or post it to url. Does not feel to be an extremely efficient solution, but probably better than intense polling of Domino server.
You probably want this to happen just while user has "connected" to his mailbox, not always process all thousands of mail files? This means the agent on Domino should have access to the info if the user is connected or not. In short - a bunch of code on Domino server that makes one think if the whole app would better be Domino based web app (depends of course on what else the app does).

OpenPop no longer downloading Message UIDs

BACKGROUND
First time using Pop3.
Using OpenPop library.
Have configured Gmail to work with Pop3.
PROBLEM
Have been debugging code to see what happens (and try to get body text). Messages downloaded first 2 or 3 times.. got the UIDs with this:
var uids = client.GetMessageUids();
This time, it is no longer fetching any UIDs and I can't figure out why. Note, I did prematurely terminate the app a couple of times. My Gmail settings are configured to keep the mails on the server even after downloading them with a pop client. I even tried setting some mails to unread status in the hope that would work, but it doesn't.
So, any ideas what would cause this method to stop working after 2 or 3 goes? Does Gmail have some kind of security issue or maybe know that this client has acquired the messages already and doesn't send the messages anymore or what?
EDIT
I sent an email to that address and now it does show 1 message. So what I really need to know is HOW does the client (or Gmail) know which messages have been downloaded or not? This is very important, because if an error occurs and I cannot store the email for my app, the next time a refresh is done, the message will not be downloaded again and so messages will be missing from the application. Is there a way to reset it? Where is this being recorded?
OpenPop does not store anything about messages by itself. It simply fetches whatever you tell it to. Gmail is a strange POP3 provider, as seen in What non-standard behaviour features does Gmail exhibit, when it is programmatically used as a POP3 server?
Gmail does not present the same message if it has been downloaded by any POP3 client. You could use the recent:username login method to see the last 30 days worth of email always.

EMAIL from web server

We have a website sending mail alerts to end users. The site has been developed in c# ASP.NET.
I want to find the best way to send the email alerts to my users. Making sure the mail is not trapped in any spam filters. I read on the internet it is best to sent the mail directly from the web server and not route via an SMTP mail service such as google apps or Postini.
Can anyone tell me if this is correct?
First of all
Making sure the mail is not trapped in
any spam filters
Is not possible - otherwise spammers would do this. You just have to make sure you're domain isn't associated with any spamming activities and watch for keywords within the email.
I read on the internet it is best to
sent the mail directly from the web
server and not route via an SMTP mail
service such as google apps or
Postini.
This point doesn't make sense - your e-mail will never be delivered if it doesn't get routed via an SMTP server, the average message will pass through multiple on its route to the recipient.
The answer is to not actually send email and let someone else deal with the problem. I'd look at postmark or Amazon's simple email service.
We had problems that mails sent with local server often get trapped in spam filters until we implemented SPF on our mail server.
http://en.wikipedia.org/wiki/Sender_Policy_Framework
But I am not admin, that's just what our admin said, and after that we have no problems anymore.
btw. maybe would be better to ask on serverfault.com

Prevent Anti-Virus to block outgoing email with C#

I have an application with a static class that is capturing all errors that happens during the runtime (if its the case) and when process is done, it sends out an email with the list of errors so I or any other developers can address those errors.
However my problem is that McAfee is blocking the request, as if it was a kind of virus. I do not have rights on my machine to edit McAfee settings, is it possible to fix it through C# code?
Thank you
Probably McAfee is blocking outgoing connections on port 25 (SMTP), only allowing a white list of applications to send email.
What you can do is:
Put the email in a mailto:// url. Execute the mailto:// as if it is a normal command line. This will ask for input from the user, but you can create a nice template for the user. (syntax)
Send the email through your normal email client (Outlook, Notes), if they have an API for that.
Use a Http/Web based provider that has an API. Public ones are probably also blocked by McAfee. But you could create & host a service yourself. Be very carefull to only allow traffic from within your company.
Maybe you company has a "drop folder", where you can drop emails that are picked up by the email server.
Depending on what/why McAfee is flagging it, more than likely you will not be able to get around it.
You will want to see if you can find out if McAfee is flagging it due to the port being used, or if there is any other information as to why the individual message is not going.
No. And yes.
No, you can't force McAffee to not flag your email from code, if that's what you mean.
Yes, you can prevent McAffee or other virus scanners from flagging your emails as suspicious. Here are a couple of things I try to make sure of:
That your all addresses (especially from: and reply-to:) are valid.
That the the name you're sending from is actually the name of a the correct person in your active directory.
You could also ask your system administrators to put your "from:" address on a global whitelist so that it always goes to the client.
Are you attaching executables? Are you sure you aren't attaching any viruses? ;-)
From what I recall, I think McAfee has a list of programmes that are allowed to send emails, if your program is not added to this list, then your emails will not get sent.
This is a big support problem, as you will find your customers have a 101 different virus checkers all setup in different ways.
You may be able to setup a email server to use a none standard port, then send emails to that port.
For testing, attaching to the McAfee process with a debugger and then killing it can work well...

How do I test my email settings without sending a message?

As part of my app's config process, I have a sanity checker that validates all user-supplied data. This includes email server settings that the app uses to send email.
I'd like a simple sanity check on those settings without actually sending any email. It'd be great if this could support all standard flavors of SMTP setups including those with authentication/ssl/etc.
It doesn't need to be exhaustive but the more coverage, the better.
Currently all I do is verify I can open a connection to the given server on the given port. Something a little deeper would be nice.
Note: I'm not trying to validate email addresses--that's not relevant to this question.
You just open a raw connection to the server & port that the user supplies and do a
HELO Server.Domain.Com
Mail From: validaccount#domain.com
to see if you get a valid HELO response & Sender OK Response
(if smtp authentication is enabled).
Same as you would do if you telnet direct to the server.
http://www.petri.co.il/test_smtp_service.htm
This might also be useful
http://qmail.jms1.net/test-auth.shtml
I'm sure someone brighter and more qualified will pipe up with a better answer. However, at first blush I'd say that you cannot verify the ability to successfully send email without actually sending an email.
However, if you want to automate the process, you can have a 'MyApp_SanityCheck#gmail.com' (or your local domain) address.
Then you can create a watchdog application that monitors that email address, or just a simple app which programmatically interfaces with that email address and checks if an email was received within X minutes. This way you can be 100% certain that the emails are able to be sent out.
This link shows how to programmatically check gmail addresses.
An important note: If you application is sending out external emails, then it would be best if the email address you use is external, because it is possible that your server could be unable to send external emails, but internal emails go through just fine, and in that case your sanity check would send up a false positive.

Categories

Resources