Я настроил шаблон aspnet для отправки писем. Я установил значения по умолчанию, используя следующее:
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)
};
}
}
Но когда я отправляю электронное письмо, оно генерирует исключение «Строка не была распознана как допустимое логическое значение», как еще я могу определить EmailSettingNames.Smtp. Свойство EnableSsl, чтобы оно правильно применялось?