Answers.Body: <p>The DB error looks to be caused by this clause: <code>(civicrm_email.location_type_id != )</code>  </p>
  
  <p>I don't know why that is occurring but check anything related to location types.  Are you using flexmailer/Mosaico?  Do you have any extensions installed that relate to mailing or email address locations?</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-01T00:21:32.110Z
Answers.Text: Not using Mosaico (couldn't get it to work), Flexmailer is still enabled though. Only other mailing extension enabled is E-mail API (org.civicoop.emailapi)
Answers.UserDisplayName: josh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-28T09:13:31.660Z
Answers.LastActivityDate: 2020-04-28T09:13:31.660Z
Answers.UserDisplayName: Aidan
Body: <p>Drupal 7.69, Civi 5.23.0</p>
  
  <p>A colleague just had an issue with CiviMail. She was trying to send a mail to Group "Volunteers" but exclude people in Group "Garden Volunteers". Instead of saying the number of recipients, it just froze on "Estimating..."</p>
  
  <p><a href="https://i.sstatic.net/8Tbvo.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/8Tbvo.png" alt="Civi estimating number of recipients"></a></p>
  
  <p>It still says estimating even if saving the draft and exiting. </p>
  
  <p>When we try to submit the mailing, it gives a DB Syntax error. </p>
  
  <p>I checked the Drupal error log and saw two relevant errors. </p>
  
  <p>Pastebin <a href="https://pastebin.com/2jGQwxHb" rel="nofollow noreferrer">link 1</a> | <a href="https://pastebin.com/W1F1ceJJ" rel="nofollow noreferrer">Link 2</a></p>
  
  <p>I ended up fixing this by just creating a new mailing with the same settings and it worked fine, but would love to work out why the initial issue happened so I Can fix it pre-emptively in case it happens again in the future.</p>
  
  <p>Flushing cache did not solve it.</p>
  
  <p>Cheers!</p>
  
  <p>--</p>
  
  <p>EDIT It's happened again, looks like it's just an issue with one particular smart group. We've definitely mailed to this smart group in the past though. </p>
  
  <p>Someone previously asked what I see when clicking on the spanner icon: </p>
  
  <p><a href="https://i.sstatic.net/fOIt7.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/fOIt7.png" alt="What I see when I click on the spanner"></a></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-28T10:23:30.053Z
Comments.Text: can you click on the wrench icon and share the screen shot?
Comments.UserDisplayName: Pradeep Nayak
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-01T00:20:00.157Z
Comments.Text: @PradeepNayak someone deleted the draft mailing unfortunately after the duplicate successfully sent out. From memory, clicking it did nothing.
Comments.UserDisplayName: josh
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-06-15T05:13:37.270Z
Comments.Text: It's happened again so I've shared a screenshot of what I see when clicking on the wrench icon
Comments.UserDisplayName: josh
Tags: <civimail><error>
Title: DB Syntax Error: CiviMail
ThreadText: # DB Syntax Error: CiviMail
  
  (Asked by: username_0 on 2020-04-28)
  
  Drupal 7.69, Civi 5.23.0
  
  A colleague just had an issue with CiviMail. She was trying to send a mail to Group "Volunteers" but exclude people in Group "Garden Volunteers". Instead of saying the number of recipients, it just froze on "Estimating..."
  
  [![Civi estimating number of recipients](https://i.sstatic.net/8Tbvo.png)](https://i.sstatic.net/8Tbvo.png)
  
  It still says estimating even if saving the draft and exiting.
  
  When we try to submit the mailing, it gives a DB Syntax error.
  
  I checked the Drupal error log and saw two relevant errors.
  
  Pastebin [link 1](https://pastebin.com/2jGQwxHb) | [Link 2](https://pastebin.com/W1F1ceJJ)
  
  I ended up fixing this by just creating a new mailing with the same settings and it worked fine, but would love to work out why the initial issue happened so I Can fix it pre-emptively in case it happens again in the future.
  
  Flushing cache did not solve it.
  
  Cheers!
  
  --
  
  EDIT It's happened again, looks like it's just an issue with one particular smart group. We've definitely mailed to this smart group in the past though.
  
  Someone previously asked what I see when clicking on the spanner icon:
  
  [![What I see when I click on the spanner](https://i.sstatic.net/fOIt7.png)](https://i.sstatic.net/fOIt7.png)
  
  **Tags:** civimail, error
  
  > **Comments:**
  > **username_1**: can you click on the wrench icon and share the screen shot?  
  > **username_0**: @username_1 someone deleted the draft mailing unfortunately after the duplicate successfully sent out. From memory, clicking it did nothing.  
  > **username_0**: It's happened again so I've shared a screenshot of what I see when clicking on the wrench icon  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2020-04-28. Score: 0
  
  The DB error looks to be caused by this clause: `(civicrm_email.location_type_id != )`
  
  I don't know why that is occurring but check anything related to location types. Are you using flexmailer/Mosaico? Do you have any extensions installed that relate to mailing or email address locations?
  
  > **Comments:**
  > **username_0**: Not using Mosaico (couldn't get it to work), Flexmailer is still enabled though. Only other mailing extension enabled is E-mail API (org.civicoop.emailapi)  
  
  ---
  
  