Mail Server Settings (edit)

  • Outlook 2010
  • Outlook 2013
  • Tài khoản email doanh nghiệp của Nhân Hòa (UMail)
  • SSL 465 smtp.umailsmtp.com
  • SSL 993 imap.umailsmtp.com

Admin: https://admin.umail.vn/

Hòm thư : https://mail.umail.vn/

UMAIL | Dịch vụ email theo tên miền riêng dành cho doanh nghiệp từ Nhân Hòa

Hướng dẫn cài đặt Umail trên Outlook Office365 - Umail | Trang hỗ trợ dành cho Umail

Hướng dẫn cài đặt Email vào Microsoft Outlook (nhanhoa.com)

Hướng dẫn gửi email bằng C# qua giao thức SMTP - Tin Học Sóc Trăng (tinhocsoctrang.com) (HAY HAY HAY)

System.Net.Mail.SmtpException: The operation has timed out. | The ASP.NET Forums (HAY HAY HAY)

How to fix (the operation has timed out) ... | DaniWeb (HAY HAY HAY)

Hướng dẫn cài đặt Umail trên Outlook 2013 - Umail | Trang hỗ trợ dành cho Umail (HAY HAY HAY)

Hướng dẫn trỏ bản ghi Umail.vn - Thư viện tài liệu tại Nhân Hòa - Nhan Hoa Software Company

Một số thư viện hay dùng:

  • SmtpClient Class (System.Net.Mail) | Microsoft Docs
  • MailKit
  • SendGrid

.net - Sending Email Using System.Net.Mail in C# - Stack Overflow

How to send emails from C#/.NET - The definitive tutorial | elmah.io

c# — Cách gửi email đến nhiều địa chỉ bằng System.Net.Mail (it-swarm-vi.com)

v2 API C# Code Example - Twilio (sendgrid.com)

Code Send Mail C#

How to fix (the operation has timed out) ... | DaniWeb

MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");

mail.From = new MailAddress(_from);
mail.To.Add(sendto);
mail.Subject = subject;
mail.IsBodyHtml = true;
mail.Body = content;

mail.Priority = MailPriority.High;

SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential(_from, _pass);
SmtpServer.EnableSsl = true;

SmtpServer.Send(mail);​SmtpClient smtp = new SmtpClient();
smtp.Host = “smtp.gmail.com”;
smtp.Port = 465;

// ----------​​----------​​----------​​----------​​----------​​----------​​----------​​----------​​----------​​

smtp.Credentials = new System.Net.NetworkCredential(“uid”, “pwd”);
smtp.EnableSsl = true;
System.Net.Mail.MailMessage message = new MailMessage(“ee@hotmail.com”, “ee@hotmail.com”, “Subject”, “Body”);

message.BodyEncoding = System.Text.Encoding.UTF8;

message.IsBodyHtml = true;
smtp.Send(message);

// ----------​​----------​​----------​​----------​​----------​​----------​​----------​​----------​​----------​​

protected void Page_Load(object sender, EventArgs e)
{
SendEmailTOAllUser();
}


protected void SendEmail(string toAddresses, string fromAddress, string MailSubject, string MessageBody, bool isBodyHtml)
{
SmtpClient sc = new SmtpClient("MAIL.companyDomainName.com");
try
{
MailMessage msg = new MailMessage();
msg.From = new MailAddress("pssp@companyDomainName.com", "PMOD Safety Services Portal (PSSP)");

// In case the mail system doesn't like no to recipients. This could be removed
//msg.To.Add("pssp@companyDomainName.com");

msg.Bcc.Add(toAddresses);
msg.Subject = MailSubject;
msg.Body = MessageBody;
msg.IsBodyHtml = isBodyHtml;
//Response.Write(msg);
sc.Send(msg);
}
catch (Exception ex)
{
throw ex;
}

}

protected void SendEmailTOAllUser()

{
string connString = "Data Source=localhost\\sqlexpress;Initial Catalog=psspEmail;Integrated Security=True";

using (SqlConnection conn = new SqlConnection(connString))
{
var sbEmailAddresses = new System.Text.StringBuilder(1000);
string quizid = "";

conn.Open();

string cmdText = "SELECT MIN (QuizID) As mQuizID FROM dbo.QUIZ WHERE IsSent <> 1";
using (SqlCommand cmd = new SqlCommand(cmdText, conn))
{
SqlDataReader reader = cmd.ExecuteReader();
if (reader != null)
{
while (reader.Read())
{
// There is only 1 column, so just retrieve it using the ordinal position
quizid = reader["mQuizID"].ToString();

}
}
reader.Close();
}

string cmdText2 = "SELECT Username FROM dbo.employee";
using (SqlCommand cmd = new SqlCommand(cmdText2, conn))
{
SqlDataReader reader = cmd.ExecuteReader();
if (reader != null)
{
while (reader.Read())
{
var sName = reader.GetString(0);
if (!string.IsNullOrEmpty(sName))
{
if (sbEmailAddresses.Length != 0)
{
sbEmailAddresses.Append(",");
}
// Just use the ordinal position for the user name since there is only 1 column
sbEmailAddresses.Append(sName).Append("@companyDomainName.com");
}
}
}
reader.Close();
}

string cmdText3 = "UPDATE dbo.Quiz SET IsSent = 1 WHERE QuizId = @QuizID";
using (SqlCommand cmd = new SqlCommand(cmdText3, conn))
{
// Add the parameter to the command
var oParameter = cmd.Parameters.Add("@QuizID", SqlDbType.Int);
// Get a local copy of the email addresses
var sEMailAddresses = sbEmailAddresses.ToString();


string link = "<a href='http://pmv/pssp/StartQuiz.aspx?testid=" + quizid + "'> Click here to participate </a>";
string body = @"Good day, <br /><br />
<b> Please participate in the new short safety quiz </b>"
+ link +
@"<br /><br />
Also, give yourself a chance to gain more safety culture by reading the PMOD Newsletter.
<br /> <br /><br /> <br />
This email was generated using the <a href='http://pmv/pssp/Default.aspx'>PMOD Safety Services Portal (PSSP) </a>.
Please do not reply to this email.
";

SendEmail(sEMailAddresses, "", "Notification of New Weekly Safety Quiz", body, true);

// Update the parameter for the current quiz
oParameter.Value = quizid;
// And execute the command
cmd.ExecuteNonQuery();
}
conn.Close();
}
}