Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Episerver Forms: object instance not set to an instance of an object when sending email



We are running the following setup for Optimizely Forms in our clients solution:

EPiServer.Forms 5.7.1
EPiServer.Forms.Samples 4.2.2

When we define our forms with a Send email actor in the editorial part of the form and submit a successfull form submission, we receive the following in the logs:

{"Timestamp":"2023-11-29T07:25:18.6347814+01:00","Level":"Error","MessageTemplate":"{State:l}","Exception":"System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.)\r\n ---> System.NullReferenceException: Object reference not set to an instance of an object.\r\n   at EPiServer.Notification.Internal.SmtpClientImplementation.SendAsync(MimeMessage message)\r\n   --- End of inner exception stack trace ---\r\n   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)\r\n   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)\r\n   at System.Threading.Tasks.Task.Wait()\r\n   at EPiServer.Forms.Implementation.Actors.SendEmailAfterSubmissionActor.<>c__DisplayClass13_0.<SendMessage>b__3()","Properties":{"State":"Failed to send email","SourceContext":"EPiServer.Forms.Core.PostSubmissionActor.PostSubmissionActorBase","ActionId":"b63041e0-adba-4e2a-abd6-70c87415f975","ActionName":"EPiServer.Forms.Controllers.DataSubmitController.Submit (EPiServer.Forms)","RequestId":"0HMVGKFJQTH3F:00000009","RequestPath":"/EPiServer.Forms/DataSubmit/Submit","ConnectionId":"0HMVGKFJQTH3F"},"Renderings":{"State":[{"Format":"l","Rendering":"Failed to send email"}]}}

The internal controller for sending an email seems to fail within Optimizely.  

This is the following configuration we have for the Smtp config for the solution:

    "Smtp": {
      "DeliveryMethod": "Network",
      "SpecifiedPickupDirectory": "C:\\Episerver\\SmtpMail",
      "Network": {
        "Host": "",
        "Port": "587",
        "UserName": "mykeyhere",
        "Password": "mypasswordhere",
        "UseSsl": true
      "Notification": {
        "NotificationEmailDisplayName": "Optimizely Notification",
        "NotificationEmailAddress": ""
    "Forms": {
      "FormsConfig": {
        "VisitorSubmitTimeout": 1,
        "DisableFormCookies": false,
        "DataExportBlobProviderName": "DefaultDataExportBlobProvider",
        "SerializingObjectUsingNameValueFormat": true,
        "SendMessageInHTMLFormat": true,
        "MinimumAccessRightLevelToReadFormData": "Edit",
        "CoreController": "/EPiServer.Forms/DataSubmit",
        "DefaultUploadExtensionBlackList": "asp,aspx,asa,ashx,asmx,bat,chm,class,cmd,com,config,dll,exe,hta,htr,htw,jse,json,lnk,mda,mdb,msc,msh,pif,printer,ps1,ps2,reg,rem,scf,scr,sct,shtm,shtml,soap,stm,svc,url,vb,vbe,vbs,vsix,ws,wsc,wsf,wsh,xamlx,htm,html,js,jar",
        "FormElementViewsFolder": "~/Views/Shared/ElementBlocks",
        "WorkInNonJSMode": false,
        "InjectFormOwnStylesheet": true,
        "InjectFormOwnJQuery": true,
        "RenderingFormUsingDivElement": false
      "FormsPermanentStorageProvider": {
        "DefaultProvider": "DdsPermanentStorage",
        "Providers": {
          "DdsPermanentStorage": {
            "Type": "EPiServer.Forms.Core.Data.DdsPermanentStorage, EPiServer.Forms.Core",
            "Parametters": {}

Have we missed something in the configuration sections or is this an internal bug for the latest Forms?


Nov 29, 2023 6:31

Could you debug your site and turn off the "Just my code" option? that would give a pretty good idea of what is null.

Looked quickly and it seems your settings and the code that send stmp mails are both correct

Nov 29, 2023 8:01

Hi Quan

I received the following exceptions while posting the form without Just my code enabled: the exception is thrown at System.Threading.Tasks and is missing the SmtpClientImplementation.cs... is this file somehow related in the nuget package of Forms?


Nov 29, 2023 11:29

Yeah try to decompile. It is not great but you can probably get what is null. 

What is your exact version, I might be able to grab you a pdb 

Nov 29, 2023 11:54

Seems to not be able to Decompile? Now I receive this SendEmailAfterSubmissionActor.cs not found

Nov 29, 2023 12:51

I decompiled with IlSpy and hence cannot find the assembly path for the SendEmailAfterSubmissionActor at EPiServer.Forms.Implementation.Actors

Nov 29, 2023 13:26

No you should only need SmtpClientImplementation - as it's throwing exception

Nov 29, 2023 14:45

SmtpClientImplementation is not thrown any longer, only SendEmailAfterSubmissionActor now - is this actor still referred in the EPiServer.Forms.Implementation.Actors namespace?

Or could we be having something else mismatch in our solution?

Nov 29, 2023 15:31

Turned out that is was a missconfiguration in the appsettings.json for the internal smtp section of the application...

Silly of me to not notice this

Dec 04, 2023 8:53
Quan Mai - Dec 06, 2023 12:18
it happens (to any of us) more than we'd like to admit :)
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.