Fast way:
//Use class: MailMessage and SmtpClient
using System.Net.Mail;
using System.Net;
[...]
private static readonly object _lockTaken = new Object();
private readonly MailAddressCollection _sendToList; // collecton emails
[...]
lock (_lockTaken) //multithread security
{
try
{
using (MailMessage mailMessage = new MailMessage())
{
mailMessage.From = _sendFrom; //MailAddress
mailMessage.Subject = _emailSubject; //string
mailMessage.Body = emailBodyMessage; //string
mailMessage.Priority = mailPriority; //MailPriority
foreach (MailAddress address in _sendToList)
{
mailMessage.To.Add(address);
}
using (SmtpClient client = new SmtpClient(_sendFromSmtp))
{
//SMTP settings can be different, my is below
client.Credentials = CredentialCache.DefaultNetworkCredentials;
client.Send(mailMessage);
}
}
}
catch (Exception ex)
{
...
}
}//lock
DONE.
Mail Expt package (includes
IMAP, POP3,
SMTP, Template Engine,
Mail Merge,
Bounce Inspector, and
Email Validator). It helps you to compose, send, read emails as well
as filter bounced email messages. In addition, you can validate email
addresses with a single line of code. You can find more info about them
at the following webblogs:
IMAP Blog,
POP3 Blog, and SMTP Blog.
Setting config file:
<mailSettings> Element
Namespaces:
Expand System.Net.Mail Namespace
System.Net.Sockets Namespace
System.Net.Security Namespace
System.Net.Mime Namespace
Basic classes:
SmtpClient Class
MailMessage Class
MailAddress Class
Attachment Class
SmtpStatusCode Enumeration
Specify exceptions:
SmtpFailedRecipientsException Class (more than one recipients)
SmtpFailedRecipientException Class (one recipient)
SmtpException Class
Articles:
http://murraymac.net/70536/Mail.aspx
http://www.asp.net-crawler.com/articles/emails/Catching-sending-emails-using-aspnet-errors-exceptions-handling.aspx
http://www.codeproject.com/Articles/5189/End-to-end-Email-Address-Verification-for-Applicat
http://www.emailarchitect.net/easendmail/sdk/html/smtpmail_deliverynotification.htm
http://luktom.net/e280-wysylanie-maili-w-c
http://csharp.net-informations.com/communications/csharp-smtp-mail.htm
http://www.answersthatwork.com/Download_Area/ATW_Library/Networking/Network__3-SMTP_Server_Status_Codes_and_SMTP_Error_Codes.pdf
http://stackoverflow.com/questions/6213741/net-smtp-send-with-smtpstatuscode-when-should-a-retry-occur
http://stackoverflow.com/questions/384119/net-smtpclient-where-is-pending-outgoing-mail-stored
http://www.codeproject.com/Articles/32434/Adding-Save-functionality-to-Microsoft-Net-Mail-Ma
http://eastgroup.pl/default.aspx?page=13
http://www.blackwasp.co.uk/SendSmtpAsync.aspx
http://www.eggheadcafe.com/articles/20030720.asp
http://www.limilabs.com/blog/read-system-net-mailsettings-smtp-settings-web-confighttp://stackoverflow.com/questions/4599779/reading-system-net-mailsettings-smtp-from-web-config-in-medium-trust-environment
http://www.codeproject.com/Articles/32434/Adding-Save-functionality-to-Microsoft-Net-Mail-Ma
http://support.mailhostbox.com/email-administrators-guide/error-codes
http://www.codicode.com/art/free_asp_net_email_validator_verifier.aspx
http://www.c-sharpcorner.com/UploadFile/kirtan007/check-if-email-address-really-exist-or-not-using-C-Sharp/
Hello, I have worked with SMTP, IMAP, POP and some related stuff for a year. I tried this code and it worked really well. I have found some examples of code at https://www.atp-inc.net/products/mail. Unfortunately, this is only a trial version, but the examples are quite well described. You should try it out to add a more complete article.
OdpowiedzUsuńThanks for the tutorial, I am sure it will be easy to use them
OdpowiedzUsuńhttps://www.atp-inc.net/
sending email, need to reduce the security of the mail account to ensure it can be spammed. Can refer to the examples at: https://www.codeultimate.com/products/mail
OdpowiedzUsuńAn alternative method is: https://www.atp-inc.net/products/email-validator. I used the source code illustration quite fully here
OdpowiedzUsuńAre these products belonging to ComponentPro? I have now downloaded the trial versions and have some questions about the FTP. Look forward to your own article on this issue.
OdpowiedzUsuńYou can find out Here
Usuń