I've setup aspnet boilerplate to send emails. I've set default values using the following:
public class AppSettingProvider : SettingProvider
{
public override IEnumerable<SettingDefinition> GetSettingDefinitions(SettingDefinitionProviderContext context)
{
return new[]
{
new SettingDefinition(EmailSettingNames.DefaultFromAddress, "", scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User, isVisibleToClients: true, isInherited: true),
new SettingDefinition(EmailSettingNames.DefaultFromDisplayName, "", scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User, isVisibleToClients: true, isInherited: true),
new SettingDefinition(EmailSettingNames.Smtp.Host, "127.0.0.1", scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User, isVisibleToClients: true, isInherited: true),
new SettingDefinition(EmailSettingNames.Smtp.Port, "25", scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User, isVisibleToClients: true, isInherited: true),
new SettingDefinition(EmailSettingNames.Smtp.UserName, XXXXX, scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User, isVisibleToClients: true, isInherited: true),
new SettingDefinition(EmailSettingNames.Smtp.Password, XXXXX, scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User, isVisibleToClients: true, isInherited: true),
new SettingDefinition(EmailSettingNames.Smtp.Domain, string.Empty, scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User, isVisibleToClients: true, isInherited: true),
new SettingDefinition(EmailSettingNames.Smtp.EnableSsl, "true", scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User, isVisibleToClients: true, isInherited: true),
new SettingDefinition(EmailSettingNames.Smtp.UseDefaultCredentials, string.Empty, scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User, isVisibleToClients: true, isInherited: true)
};
}
}
But when I send the email it generates an "String was not recognized as a valid Boolean" exception, how else do I define the EmailSettingNames.Smtp.EnableSsl property so that it applies correctly?
Below is the correct one:
public class AppSettingProvider : SettingProvider
{
public override IEnumerable<SettingDefinition> GetSettingDefinitions(SettingDefinitionProviderContext context)
{
return new[]
{
new SettingDefinition(EmailSettingNames.DefaultFromAddress, "", scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User, isVisibleToClients: true, isInherited: true),
new SettingDefinition(EmailSettingNames.DefaultFromDisplayName, "", scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User, isVisibleToClients: true, isInherited: true),
new SettingDefinition(EmailSettingNames.Smtp.Host, "127.0.0.1", scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User, isVisibleToClients: true, isInherited: true),
new SettingDefinition(EmailSettingNames.Smtp.Port, "25", scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User, isVisibleToClients: true, isInherited: true),
new SettingDefinition(EmailSettingNames.Smtp.UserName, XXXXX, scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User, isVisibleToClients: true, isInherited: true),
new SettingDefinition(EmailSettingNames.Smtp.Password, XXXXX, scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User, isVisibleToClients: true, isInherited: true),
new SettingDefinition(EmailSettingNames.Smtp.Domain, string.Empty, scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User, isVisibleToClients: true, isInherited: true),
new SettingDefinition(EmailSettingNames.Smtp.EnableSsl, "true", scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User, isVisibleToClients: true, isInherited: true),
new SettingDefinition(EmailSettingNames.Smtp.UseDefaultCredentials, "false", scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User, isVisibleToClients: true, isInherited: true)
};
}
}
Corrected: UseDefaultCredentials
cannot be empty string.