evoke it logo white with clear backQuick Contact

Debugging Emails in C# Microsoft SharePoint

Debugging Emails in C# Microsoft SharePoint

There is a couple of ways to debug software in C# Microsoft SharePoint which sends out emails – without actually sending out those emails to users.

Adding a simple #IF DEBUG line around the line of code which actually sends the email will allow you to check that is configures everything correctly, but without the need to post out as this code gets skipped when Visual Studio is set up in debug mode.

The code is now in release mode on a fully configured server – so will start sending emails to users filled with test data.

A better option is to add a variable to your web.config which details the environment we are in; dev, test or prod. Once this is in place we can set up options for each in a switch statement. In production we should actually send the email, in test we could send the email but only to one specific user; and in dev we could log the whole email to the ULS logs for inspection later on.

Now you can step through your code, or let it run knowing that emails won’t be leaking from your development site.

Be the First to Get Our Ebook
Microsoft SharePoint 2019

What you need to know!

Back To The BlogContact Support

View Post's Via Catagory

IT support laptop image
Software Development cloud image
Terms & ConditionsPrivacy PolicyDeveloped by Evoke IT