Tuesday, January 19, 2010

SendEmailNotification not sending emails

This is a tough one. There could be a whole bunch of reasons why your workflow tasks are not sending the OOB emails when a task is assigned. Here are just a few symptoms and their solutions

1) No emails are being sent, not receiving alerts
-Check your SMTP settings in Central Administration. Under Operations you will find Outgoing Email Settings. Make sure that a valid SMTP server is entered there. Either your local machine is running the smtp service which means the local machine name should be there or you are using an external smtp server to send your emails

-Try to connect to the smtp server using telnet on port 25.
a) open up a command prompt
b) type in: telnet smtp.yourserver.com 25
c) If you can connect, type in EHLO or HELO. If any of those give you back useful message your SharePoint Server is able to communicate with your smtp server.
Try sending a test message via telnet:
MAIL FROM:someemail@domain.com
RCPT TO:validemail@domain.com
DATA email body
Test email message

Done. Make sure to do the CRLF.CRLF bit to send of the message. If it arrives, then you can rest assured that no smtp server config or firewall is blocking your SharePoint server.

Still no emails?
Make sure that the Windows SharePoint Timer Service is set to automatic and is currently in a running state. If that service crashed, or if someone stops it, no jobs will run, including the task emails and alerts.

Still plum out of luck? (been flying too much Air New Zealand lately) Make sure that the user has an email address defined!!! This sounds simple but can be a bitch when using MOSS.
When using WSS, simply click the header where it says Welcome Dude and select Edit my Settings from the dropdown. Add the missing email.
If using MOSS, you will need to update your profile either using your MySite, but if that is not available, go to the SSP Admin site and edit the profile manually there. But beware! Those changes might take some time to trickle down to your different site collections. To speed up the process open a command on the server and type stsadm -o sync
That will kick start the profile sync bewteen the profile store in SSP and the UserInfo Lists in the different SharePoint Sites.

Problem: You still can not see your changes on the userdisp.aspx pages of your site collections. even after executing the sync command and waiting a few moments paitently.
Reason: the user you are looking at is in the system, but not set as active in SharePoint. The only way to activate a user in SP is for that user to log in and do stuff. like adding, editing or deleting list items or documents. So do some stuff and execute the sync command again. That should do the trick.

So now you can see the email address on the user profile page (userdisp.aspx) but still not receiving task emails for your custom workflow tasks...
Maybe you're just impatient. the timer job is set to run every 5 minutes. to speed this up you can change the frequency using stsadm -o setproperty
the property you're looking for is job-immediate-alerts
the value is "Every 1 minute between 0 and 59"
But set that property at your own risk. It will also affect alerts on the farm.

EMail is set, user is active, smtp is behaving and the Timer Service is running, but no emails from your custom workflow.

Solution: First test if you get emails for any OOB workflows like approval and Feedback. If so, then there is an issue with multiple applicaitons using the same task list. I found assigning a new Task list for my custom workflow resolved this issue and SharePoint would send out mails for new tasks as expected. This behaviour is often caused when sites are exported and imported using stsadm. Not all settings are correctly migrated causing this behaviour to crop up. Another reason to be wary of using the export and import functionality in SharePoint to migrate solutions...


Ryan said...

I've been putting together a troubleshooting guide for SharePoint Alerts.


alx said...

Hey Ryan, nice little resource you put together. good work!

Paul said...

Great work. I'm using an event Item Added receiver to mimic sending task notification emails. The event receiver class, sends mail via EWS, Exchange Web Service.

Paul said...

Great article. Had similar issues, so I had to code an Item Added event receiver and attach it to the Task list, so as to speed up the process. The item receiver class, sends mail directly through exchange, using EWS(Exchange WebServices).