Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

When I try to send an email from a workflow I get the famous error "The e-mail message cannot be sent. Make sure the outgoing e-mail settings for the server are configured correctly". I have added the IP for the SMTP server in central admin -> outbound email and if I put an alert on a list and create a new item I get the alert so what am I missing here? Why can SharePoint email alerts but not from workflows?

Thanks in advance.

share|improve this question
    
Is this an OOTB workflow or a custom workflow? –  Russell Dec 21 '11 at 6:07
    
custom workflow with one action: send email to user who created the item in the list –  John Dec 21 '11 at 6:09
1  
ok, can you give a brief summary of the steps for your workflow? This may help diagnose the issue. –  Russell Dec 21 '11 at 6:11
add comment

4 Answers

Sometimes pause steps can impact email sending during workflows. This link http://social.msdn.microsoft.com/forums/en-US/sharepointworkflow/thread/6e848a25-019d-4220-aff6-c535da933e0f/ has some info on when pause steps can prevent emails being sent.

Keep it simple and create a test workflow wiht a single email step. Does that work?

Also confirm that the user being sent the email has the correct email setup in AD too. Was the alert for the same person?

share|improve this answer
    
It's the simplest workflow possible (no other step/action than send email) and the alert was for the same user on the same list. I also tried to put my own email in a workflow variable and send it to that address but same error. –  John Dec 21 '11 at 23:55
    
Can you check the SMTP logs and see if the email is sent (perhaps to an invalid email) or if it is actually sent to the mail server? –  Russell Dec 21 '11 at 23:59
add comment

Have you checked whether there is any anti virus software running in the background which is blocking the emails to be sent. Better still why don't you create a simple workflow with an sending email step and see whether it sends any mail. Are you able to send emails when adding users in a group or adding permissions. Try these steps and tell me if you face any problem.

Thanks, Sachin

share|improve this answer
    
I created the simplest workflow possible, send email to an address when an item is created and it does not send the email. I checked the event viewer on the server and it says "Cannot connect to the SMTP server" so it makes sense that it can't send emails from the workflow but it did manage to send email when I added an alert on the same list and this puzzles me. Unfortunately I don't have access to the server today to check whether an email is sent when I add a person to a group. –  John Dec 21 '11 at 23:54
    
Anti-virus would have stopped all emails from SharePoint, but @John said alerts were still being sent by email. –  Russell Dec 21 '11 at 23:59
add comment

If there are multiple WFEs , try to whitelist all the sharepoint servers in Exchange. That can be another potential cause of mails dropping off.

Once done, perhaps an IISRESET can do the job.

You need to verify your exchange entries to see if mails are even reaching from SharePoint to exchange through your workflows.

share|improve this answer
add comment

I also did send mail by custom workflow. I have use below methods. both method working fine.

First Method

private bool sendEmail(SPWeb web, string from, string to, string cc, string bcc, string subject, string body)
    {

        try
        {
            StringDictionary headers = new StringDictionary();
            headers.Add("to", to);
            headers.Add("cc", cc);
            headers.Add("bcc", bcc);
            headers.Add("from", from);
            headers.Add("subject", subject);
            headers.Add("content-type", "text/html");
            bool flag = SPUtility.SendEmail(web, headers, body);
            if (flag)
                return true;
        }
        catch
        {

            return false;
        }
        return false;
    }

}

Second Method

public static bool SendMail(string Subject, string Body, bool IsBodyHtml, string From, string To, string Cc, string Bcc)
    {
        bool mailSent = false;
        try
        {
            SmtpClient smtpClient = new SmtpClient();
            smtpClient.Host = SPContext.Current.Site.WebApplication.OutboundMailServiceInstance.Server.Address;
            MailMessage mailMessage = new MailMessage(From, To, Subject, Body);
            if (!String.IsNullOrEmpty(Cc))
            {
                MailAddress CCAddress = new MailAddress(Cc);
                mailMessage.CC.Add(CCAddress);
            }
            if (!String.IsNullOrEmpty(Bcc))
            {
                MailAddress BCCAddress = new MailAddress(Bcc);
                mailMessage.Bcc.Add(BCCAddress);
            }
            mailMessage.IsBodyHtml = IsBodyHtml;
            smtpClient.Send(mailMessage);
            mailSent = true;
        }
        catch (Exception ex) 
        {

            return mailSent; 
        }
        return mailSent;
    }
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.