I'm trying to use Postal to send out emails from a service (not in an ASP.NET project). I keep getting exceptions with the following message:
error CS0103: The name 'model' does not exist in the current context
I'm following the tutorial from the Postal wiki: https://github.com/andrewdavey/postal/wiki/Postal-in-non-web-scenario
My template looks like:
@model Namespace1.AlertEmailViewModel
From: [email protected]
To: @Model.FirstName @Model.LastName <@Model.Email>
Subject: Alert! @Model.ShortDescription
(The model class in question does exist.)
Any help would be appreciated. Thanks!
As you are using Postal in a non-web scenario, under the hood it is using our RazorEngine project. Currently, this means it is utilising the v2.1 release currently pushed on NuGet.
The
@model
syntax isn't supported natively in v2.1, but the upcoming v3 release includes this support, as well as other nice things like layouts, thread-safety etc. (https://github.com/Antaris/RazorEngine)