Rob Kraft's Software Development Blog

Software Development Insights

Archive for the ‘I.T.’ Category

Resolving SQL Server DatabaseMail Error:  Cannot send mails to mail server. (Failure sending mail.)

Posted by robkraft on February 7, 2022

I learned some information I thought could help others more quickly resolve this error on SQL Server. As security demands increase, some features of older versions of products get more difficult to maintain. In this case, I am supporting a SQL Server running on SQL Server 2014. It has the latest Cumulative Update applied (CU) yet the emails sent via DatabaseMail are still failing. They were failing occasionally but began to fail consistently after applying one of those recent updates. In conjunction with the updates we applied registry entry changes in an attempt to get SQL Server to support TLS 1.2+ with Microsoft Office Email on Smtp.office365.com port 587.

The error we received from the failed emails was very vague:

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 3 (2022-01-31T06:18:01). Exception Message: Cannot send mails to mail server. (Failure sending mail.).

I used this simple script to test sending emails:

declare @rc int
  exec @rc = msdb.dbo.sp_send_dbmail
      @profile_name = N'SQLSend',
      @recipients         =  'myemail@mail.com',
      @subject    = N'*** Test by me ***',
      @body     = 'email body'

I wrote a C# .Net program to see if I could get more error detail. I didn’t know what version of .Net Framework was on the server so I compiled against .Net 2.0 and ran my program and got the same error. Then I compiled my program on .Net 4.8 and got a different error. What I learned was that the newer version of the .Net framework (anything 4.0 or higher) provides a more detailed error message.

So my next task was to figure out if SQL Server is using the .Net Framework to send the Email (which I think it is) and how to tell SQL Server to use a newer version of the .Net Framework.

SQL Server uses an executable named DatabaseMail.exe to send the email. That program will exist in a folder named something like: D:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Binn

There program is a .Net program and therefore includes a .Config file. Or, I should say, it “can” include a config file. I think what happened is that .config file for our DatabaseMail.exe got deleted when an SQL Server update was installed (as mentioned in this article: https://support.microsoft.com/en-us/topic/kb3186435-fix-sql-server-2016-database-mail-does-not-work-on-a-computer-that-does-not-have-the-net-framework-3-5-installed-or-stops-working-after-applying-sql-server-update-3480beb6-1329-74d6-0f3a-e8e3d893326c

So I used notepad to create a new file named databasemail.exe.config in the same folder, and I put this content into the file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="DatabaseServerName" value="." />
    <add key="DatabaseName" value="msdb" />
  </appSettings>
  <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
</configuration>

By telling DatabaseMail.exe to use .Net Framework 4.5, we were able to get a more detailed error message from the failed emails. In our case, the error we got by using .Net Framework 4.5 is shown below. Our belief is that one of the SQL Server updates somehow altered the existing configured password of the hashing or encryption algorithm used for it. We simply re-entered our password in DatabaseMail configuration and our email started working again.

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 3 (2022-02-01T12:47:47). Exception Message: Cannot send mails to mail server. (The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 Client not authenticated to send mail. Error: 535 5.7.139 Authentication unsuccessful, the user credentials were incorrect.

Posted in I.T., SQL Server | 5 Comments »

Trello Removes Feature for Creating Personal Board – A Setback From Their Atlassian Acquisition

Posted by robkraft on February 10, 2021

I discovered today that Trello no longer supports personal boards.  When you create a new board you need to create it within a Team first (teams will be renamed workspaces).

You can get around this by just creating your own team, perhaps name your team Personal.  But I see this as the first of many steps where Atlassian is re-purposing a popular tool for personal time management into a product optimized for users of other Atlassian products.  It is sad when a good product is acquired by another company then altered for different end users.

As I suspect more changes in the future, probably even pricing related, I am hunting for alternatives to Trello now.  There is a good list of some in this article:  The 17 Best Trello Alternatives in 2021 (In-Depth Comparisons) (kinsta.com)

Asana and Wrike are a few good alternatives.

Here is Atlassian trying to put a positive speed on their product degradation: Why can’t I create a board outside of a team anymore? – Trello Help

Posted in Project Management, Web Sites | Leave a Comment »

Forcing dynamic content to render Client-Side on a Netlify Gridsome SSR Vue Site

Posted by robkraft on January 19, 2021

I inherited a site build on Netlify using Gridsome and Vue Server-Side Rendering (SSR).  The site is pretty good.  It loads very fast and the content is easily maintained by people that are not programmers.  However, we occasionally want to embed a form from another site, such as OpenForms.com, and that is challenging.  The idea behind Vue SSR is that the server will render and load ALL the content then provide it to the browser, and trying to run JavaScript on the client is challenging because traditional events used by SPA and web page JavaScript programmers don’t fire.

Furthermore, the Gridsome CMS uses Markdown for web page content, but the ability to place HTML and JavaScript in these pages is limited.  I battled for days to create a solution and am sharing how I made it work.  I’ll admit it may not be the best solution; please let me know if there is a better way; but this solution works robustly.

Step 1: In the Gridsome MarkDown page, add the anchor tag that links to your form as provided by OpenForms.  Something like this:

<a class="openforms-embed" href="https://us.openforms.com/Form/{your form ID here}">Click here to view form.</a>

I did not include the script tag to load the JavaScript here because it won’t load reliably here, so I load it elsewhere.

Step 2: On the Vue page that renders the MarkDown page from Step 1, add code in the mounted() and updated() events. (The console.log is not necessary, but I use it to help me understand what is going on.)

export default {
   mounted() {
     console.log("mounted basic: " + window.location.pathname);
    evalScripts()
    
  },
  updated() {
    console.log("updated basic: " + window.location.pathname);
    evalScripts()
  },

Step 3: The important piece is calling the evalScripts() method I wrote which is this:

function evalScripts() {
  //This SeamlessOpenForms is specific to USOpenForms to get an openform to render every time 
  //the page is refreshed or viewed.
  if (typeof(SeamlessOpenForms) != 'undefined')
  {
      SeamlessOpenForms.loadOpenForms();
  }
  else {
      const openforms = document.querySelectorAll(".openforms-embed");
      if (openforms.length>0)
      {
        console.log("missing SeamlessForms: " + window.location.pathname);
        const scriptPromise = new Promise((resolve, reject) => {
          var scriptElement = document.createElement('script');  
          document.body.appendChild(scriptElement);
          scriptElement.src = 'https://us.openforms.com/Scripts/embed-iframe.js';  
          scriptElement.onload = resolve;
          scriptElement.async = true;
        });
        scriptPromise.then(() => { SeamlessOpenForms.loadOpenForms();});
    }
  };
}

I will attempt to explain what I think is going on with USOpenForms and the code above.  First of all, this code is risky because I reviewed the JavaScript in https://us.openforms.com/Scripts/embed-iframe.js provided by OpenForms to figure out what to do here, and it is very possible that OpenForms will change their JavaScript and what I am doing here will no longer work (our fallback is to put this in an Iframe, but that causes two vertical scroll bars).

When the JavaScript file (embed-iframe.js) loads it executes and looks for any anchor tags in the DOM with a class of .openforms-embed.  If it finds an item with that tag, it uses the src property to pull in the form and render it within the current page.  However, if a user navigates first to another MarkDown page, based on the same Vue Page, the embed-iframe.js looks for those anchor tags on that MarkDown page and does not find them.  When the user navigates to the MarkDown page containing the anchor tag, the embed-iframe.js does not load and run to look for anchor tags because it already did so when the first MarkDown page for that Vue component loaded.

The script above, gets called by either the mounted() or updated() event, one of which will fire every time a MarkDown page is loaded or refreshed.  The script will render the OpenForm via SeamlessOpenForms.loadOpenForms() if the JavaScript to do so is already loaded, but if not it will dynamically load that JavaScript, then perform the render code (SeamlessOpenForms.loadOpenForms();)

FYI – Here is a simple example of loading the form in an IFrame, which is what we did initially in the MarkDown until I got the embedded form JavaScript to work.

<iframe height="600px" width="100%" style="border:none;" src="https://us.openforms.com/Form/{your form id}"></iframe>

The explanation:

In the Gridsome/Vue SSR architecture, some window/DOM events only fire when the first web page (the first MarkDown page) based on that Vue Page is loaded.  So if you have dozens of MarkDown files that all use the same Vue Page (such as BasicPage.Vue), some javascript methods and Vue events only run when the first MarkDown page based on the Vue Page is loaded.  But the mounted() or updated() events always fire when a MarkDown page is loaded, rendered, or refreshed.

Posted in Coding, Web Sites | Leave a Comment »

How To Fix Scaling Problem for High DPI PC Running Kali Linux

Posted by robkraft on March 11, 2020

I couldn’t find any posts on the web telling me the best way to fix this problem so I am sharing my solution here.

The problem I experienced is that I downloaded Kali Linux to run in VMPlayer on my High DPI Windows 10 machine but the guest font and screen is too small and hard to read to be really usable.  VMPlayer doesn’t have any settings to fix this, but you can change the VMPlayer.exe settings in the Windows host OS to fix it.

Find your VMPlayer.exe, probably in a folder like C:\Program Files (x86)\VMware\VMware Player.  Right-click on it, select Properties, Compatibility Settings.  Then click on the “Change high DPI settings”.

I checked the checkbox labeled “Use this setting to fix scaling problems for this program instead of the one in Settings”.

I also checked “Override high DPI Scaling behavior.  Scaling performed by System”.

When I restarted VMPlayer and opened Kali Linux, the UI was much more functional and usable, once I opened it full screen.

Posted in I.T. | Leave a Comment »

Free Tool from F-Secure To Check If Your Password Was Compromised

Posted by robkraft on March 11, 2020

F-Secure has an easy online tool you can use to find out what sites leaked your email address, password, and other information.

The URL is: https://www.f-secure.com/en/home/free-tools/identity-theft-checker

F-Secure is a site I trust and recommend.  Just enter your email address and within minutes you will receive an email with information about each breach your email address was part of.

F-Secure has other tools at https://www.f-secure.com/en/home/products#free such as a tool to show your IP address, a tool to check your router for flaws, and an online virus scanner for your PC.

Posted in Home Tech, I.T. | Leave a Comment »

Asp.Net Core – HTTP Error 500.0 – ANCM In-Process Handler Load Failure

Posted by robkraft on October 30, 2019

I spent a few hours trying to fix this problem today.  What I thought was strange was that one web site loaded and worked fine, and another web site, on the same server using the exact same files did not work.

Our fix turned out to be somewhat simple.  You can only have one Asp.Net Core module running in process per IIS App Pool.  We have long been sharing an app pool with several web sites.  I guess as we migrate to Asp.Net Core running on IIS, that we will need to create a separate App Pool for each site.

I figured this out by reviewing the Event Viewer Application logs.

“Only one inprocess application is allowed per IIS application pool. Please assign the application ‘/LM/W3SVC/1/ROOT/Nightly/SQL2012/LucityDocumentServerCore’ to a different IIS application pool.”

Eventi ID 1008

 

  • HTTP Error 500.0 – ANCM In-Process Handler Load Failure
  • The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.
  • The in process request handler, Microsoft.AspNetCore.Server.IIS, was not referenced in the application.
  • ANCM could not find dotnet.
  • failed to start application iis aspnetcore module v2 0x80004005

Posted in I.T., Web Sites | Leave a Comment »

How To Activate Function Key Lock On Your Lenovo Yoga

Posted by robkraft on June 14, 2019

This post is primarily for myself to find the answer when I need to change the default way function keys behave on my Lenovo computer again.

To do this, launch the “Lenovo Vantage” app in Windows 10.  From there select “Hardware Settings” and then “Input”.

LenovoVantage

Selecting the highlight option will cause your function keys to behave like most software programmers expect them to behave.  Very helpful for a developer like myself that is used to using F8 and F10, not to mention all the helpful Windows function keys:

https://www.computerhope.com/issues/ch000306.htm

Posted in Home Tech, I.T., Uncategorized | Leave a Comment »

I Was A Victim of Microsoft’s Attempt to Fix Meltdown and Spectre

Posted by robkraft on April 15, 2018

If you’ve come here hoping for a rant against Microsoft, prepare to be disappointed.  Microsoft released a patch on January 5th, 2018 to attempt to fix Meltdown/Spectre problems.  That patch prevented one of my computers from booting after it was applied.  I am not upset with Microsoft for causing this problem while attempting to fix another program because I understand that fixing some problems are really difficult, and what works on one CPU may not work on another.  Fortunately for me, the computer affected by this patch was a computer I do not use often.

Unfortunately, this is a problem that would cause most people, anyone that does not consider themselves pretty good at fixing computer problems, from using the computer until they took it to someone else for repair.

Today I sat down to fix the computer.  The computer runs Windows 7.  The computer failed to boot on January 11th, 2018.  I discovered the boot failure a few weeks later and then discovered that I could not even enter Windows Safe Mode after rebooting the PC.  Knowing it would take some time to resolve the problem and that I might have a corrupt hard drive and never be able to resolve it, I put an attempt at resolution on hold.

Until today.

I used a Windows 10 bootable jump drive I already owned.  My HP machine allows me to press the ESC key to get to the “Boot Menu” and from there I could select the Jump Drive.  I chose to go to the command prompt.  From there, I found my C: drive (which was named E: in this boot) and found that all my backup files still existed.  I breathed a small sigh of relief then searched (dir /od) looking to find when the PC last successfully booted (which was January 11th), and I looked for an explanation of the problem by looking for what last happened on the machine.  I saw that Windows Update had activity just prior to the failure.  I then searched the Internet from another computer and quickly found the exact article I needed to fix the problem.

https://www.sevenforums.com/general-discussion/412283-windows-7-wont-start-after-update-5-jan-2018-a-2.html?s=059ef7f74b20ace7ea26687e027217b2

I used the information in the January 8th post by Wolfie1307 to run the following command and the command told me it succeeded (meaning that it successfully rolled back the attempted Windows Update).

dism /image:E:\ /remove-package /packagename:Package_for_RollupFix~31bf3856ad364e35~x86~~7601.24002.1.4(or whatever you copied) /norestart

It did not work for me on my first attempt because I was lazy and used the exact package name that Wolfie1307 provided in his/her post.  I needed to change the package name to include x86 instead of amd64 for mine to succeed, and I found the name of that package in the WindowsUpdate.log

I rebooted my computer and it is working again!

 

 

Posted in Home Tech, I.T. | Leave a Comment »

Ending Net Neutrality Will Cost You!

Posted by robkraft on December 3, 2017

23905246_1764216676942296_1922093923842125536_n

Posted in I.T. | Leave a Comment »

iTunes 12.7 Problem – Podcasts missing from Library

Posted by robkraft on October 22, 2017

It seems that most iTunes Upgrades either cause problems or remove features I use for managing the podcasts I listen to and 12.7 was no different.  This one took me an hour to resolve.  Unfortunately Apple has no information about this on their site and it is not easy to submit or get responses to support requests.  But I found the answer on another blog: https://appletoolbox.com/2017/09/apple-releases-new-itunes-12-7-what-you-should-know/#Where_Are_My_Podcasts

I am reposting the resolution on my blog in case I need to again, and maybe to reduce the time it takes for others to resolve the problem.

Posted in Home Tech, Uncategorized | Leave a Comment »