This is a small wrapper around the .net SMTP Email services
More...
|
| TSmtpSender () |
| Set up the SMTP client More...
|
|
void | SetSender (string AAddress, string ADisplayName) |
| Sets the sender address for the email - or set of emails. More...
|
|
void | AddAttachment (string ADisplayFileName, string APhysicalFileName) |
| add an attachment with a different name to avoid temp names in the email More...
|
|
MimeMessage | GetNewMimeMessage () |
| Returns a new MimeMessage with From, Reply-To and CC addresses set from the values in User Defaults. More...
|
|
bool | SendEmail (string fromemail, string fromDisplayName, string recipients, string subject, string body, string[] attachfiles=null) |
| Create a mail message and send it as from the specified sender address. More...
|
|
bool | SendEmailFromTemplate (string fromemail, string fromDisplayName, string recipients, string template, string language, Dictionary< string, string > parameters, string[] attachfiles=null) |
| Create a mail message from a language specific template and send it as from the specified sender address. The first line in the template is the subject, all following lines are the body. More...
|
|
bool | SendEmail (string recipients, string subject, string body, string[] attachfiles=null) |
| Create a mail message and send it as from the address that has already been set. More...
|
|
bool | SendMessage (MimeMessage AEmail) |
| Send an email message More...
|
|
void | Dispose () |
| Dispose of the IDisposable objects used by this object. More...
|
|
|
static readonly String | EMAIL_USER_LOGIN_NAME = "IUSROPEMAIL" |
| todoComment More...
|
|
static readonly String | SMTP_HOST_DEFAULT = ".example.org" |
| The domain of the default dummy SmtpHost written to our Server.config. Used here to check whether SMTP has been configured. More...
|
|
static readonly string | RECENTADDRS = "EmailRecentAddresses" |
| User Default code for the list of most recently used email addresses. More...
|
|
This is a small wrapper around the .net SMTP Email services
◆ TSmtpSender()
Ict.Common.IO.TSmtpSender.TSmtpSender |
( |
| ) |
|
|
inline |
◆ AddAttachment()
void Ict.Common.IO.TSmtpSender.AddAttachment |
( |
string |
ADisplayFileName, |
|
|
string |
APhysicalFileName |
|
) |
| |
|
inline |
add an attachment with a different name to avoid temp names in the email
◆ ConvertAddressList()
static List< MailboxAddress > Ict.Common.IO.TSmtpSender.ConvertAddressList |
( |
string |
AList | ) |
|
|
inlinestatic |
Convert a semicolon-separated list of email addresses to a list of email address objects.
Where OpenPetra has multiple addresses stored in one database field, most are separated by semicolons because by default Microsoft Outlook requires semicolons to separate addresses (https://blogs.msdn.microsoft.com/oldnewthing/20150119-00/?p=44883). But the Internet, including .NET's MailMessage.To.Add(string) method, requires commas (https://tools.ietf.org/html/rfc5322#section-3.4). So when pulling "To" addresses from the database we must parse them for unquoted semicolons and convert them to commas.
- Parameters
-
- Returns
◆ Dispose()
void Ict.Common.IO.TSmtpSender.Dispose |
( |
| ) |
|
|
inline |
Dispose of the IDisposable objects used by this object.
◆ GetNewMimeMessage()
MimeMessage Ict.Common.IO.TSmtpSender.GetNewMimeMessage |
( |
| ) |
|
|
inline |
Returns a new MimeMessage with From, Reply-To and CC addresses set from the values in User Defaults.
- Returns
- A MimeMessage
- Exceptions
-
◆ GetSmtpSettingsFromAppSettings()
Method to obtain the SMTP email server configuration settings from the configuration file.
◆ SendEmail() [1/2]
bool Ict.Common.IO.TSmtpSender.SendEmail |
( |
string |
fromemail, |
|
|
string |
fromDisplayName, |
|
|
string |
recipients, |
|
|
string |
subject, |
|
|
string |
body, |
|
|
string[] |
attachfiles = null |
|
) |
| |
|
inline |
Create a mail message and send it as from the specified sender address.
- Returns
- Flag indicating whether email was sent.
- Exceptions
-
◆ SendEmail() [2/2]
bool Ict.Common.IO.TSmtpSender.SendEmail |
( |
string |
recipients, |
|
|
string |
subject, |
|
|
string |
body, |
|
|
string[] |
attachfiles = null |
|
) |
| |
|
inline |
Create a mail message and send it as from the address that has already been set.
The sender address must be set using SetSender(string, string)
- Returns
- Flag indicating whether email was sent. Check the ErrorStatus property for further details.
- Exceptions
-
◆ SendEmailFromTemplate()
bool Ict.Common.IO.TSmtpSender.SendEmailFromTemplate |
( |
string |
fromemail, |
|
|
string |
fromDisplayName, |
|
|
string |
recipients, |
|
|
string |
template, |
|
|
string |
language, |
|
|
Dictionary< string, string > |
parameters, |
|
|
string[] |
attachfiles = null |
|
) |
| |
|
inline |
Create a mail message from a language specific template and send it as from the specified sender address. The first line in the template is the subject, all following lines are the body.
- Returns
- Flag indicating whether email was sent.
- Exceptions
-
◆ SendMessage()
bool Ict.Common.IO.TSmtpSender.SendMessage |
( |
MimeMessage |
AEmail | ) |
|
|
inline |
Send an email message
- Parameters
-
AEmail | On successful sending, the header is modified with the sent date. |
- Returns
- True if email was sent successfully.
◆ SetSender()
void Ict.Common.IO.TSmtpSender.SetSender |
( |
string |
AAddress, |
|
|
string |
ADisplayName |
|
) |
| |
|
inline |
Sets the sender address for the email - or set of emails.
- Parameters
-
◆ ValidateEmailAddress()
static bool Ict.Common.IO.TSmtpSender.ValidateEmailAddress |
( |
string |
field | ) |
|
|
inlinestatic |
Static method that can be called from anywhere to validate an email address.
- Parameters
-
- Returns
- True if the string forms a valid email address; false otherwise.
◆ EMAIL_USER_LOGIN_NAME
readonly String Ict.Common.IO.TSmtpSender.EMAIL_USER_LOGIN_NAME = "IUSROPEMAIL" |
|
static |
◆ RECENTADDRS
readonly string Ict.Common.IO.TSmtpSender.RECENTADDRS = "EmailRecentAddresses" |
|
static |
User Default code for the list of most recently used email addresses.
◆ SMTP_HOST_DEFAULT
readonly String Ict.Common.IO.TSmtpSender.SMTP_HOST_DEFAULT = ".example.org" |
|
static |
The domain of the default dummy SmtpHost written to our Server.config. Used here to check whether SMTP has been configured.
◆ BccEverythingTo
String Ict.Common.IO.TSmtpSender.BccEverythingTo |
|
set |
Use this to get all the emails blind copied to an address
◆ CcEverythingTo
String Ict.Common.IO.TSmtpSender.CcEverythingTo |
|
set |
Use this to get all the emails copied to an address
◆ ErrorStatus
string Ict.Common.IO.TSmtpSender.ErrorStatus |
|
get |
An indication of any errors that occurred during SendMessage.
◆ FailedRecipients
After SendMessage, this contains a list of any recipients we failed to send to.
◆ GetSmtpSettings
Client or Server Delegate used to get the SMTP server settings.
◆ ReplyTo
String Ict.Common.IO.TSmtpSender.ReplyTo |
|
set |
If the ReplyTo address should be different, use this.
◆ Sender
MailboxAddress Ict.Common.IO.TSmtpSender.Sender |
|
get |
Returns the sender address for use if constructing a MimeMessage outside this class.
The documentation for this class was generated from the following file: