How to convert OpenPop.NET MailMessage to System.Net.Mail.MailMessage?
By : user2616037
Date : March 29 2020, 07:55 AM
|
ASP.NET MailMessage.BodyEncoding and MailMessage.SubjectEncoding defaults
By : Jestem Tutaj
Date : March 29 2020, 07:55 AM
will be helpful for those in need For MailMessage.BodyEncoding MSDN says: code :
internal void set_Subject(string value)
{
if ((value != null) && MailBnfHelper.HasCROrLF(value))
{
throw new ArgumentException(SR.GetString("MailSubjectInvalidFormat"));
}
this.subject = value;
if (((this.subject != null) && (this.subjectEncoding == null)) &&
!MimeBasePart.IsAscii(this.subject, false))
{
this.subjectEncoding = Encoding.GetEncoding("utf-8");
}
}
internal static bool IsAscii(string value, bool permitCROrLF)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
foreach (char ch in value)
{
if (ch > '\x007f')
{
return false;
}
if (!permitCROrLF && ((ch == '\r') || (ch == '\n')))
{
return false;
}
}
return true;
}
|
e-mail IsBodyHtml=false without urls or mailto
By : Uma Mahesh
Date : March 29 2020, 07:55 AM
Hope this helps This is caused by the email client (Outlook, Gmail, etc.) parsing the URL for your convenience. If you look inside the Body property of the MailMessage object, you would have no HTML link (
|
Allow null for To, Cc, Bcc of mailmessage (system.net.mail.mailmessage)
By : Romain Piquot
Date : March 29 2020, 07:55 AM
I hope this helps . I am using System.Net.Mail.MailMessage to capture and pass it over the info related to email. , As Hans inferred in his comment, something like code :
bool send = false;
if (!String.IsNullOrEmpty(mailMsg.To))
{
mailMessage.CC.Add(mailMsg.To);
send = true;
}
if (!String.IsNullOrEmpty(mailMsg.Cc))
{
mailMessage.CC.Add(mailMsg.Cc);
send = true;
}
if (!String.IsNullOrEmpty(mailMsg.Bcc))
{
mailMessage.CC.Add(mailMsg.Bcc);
send = true;
}
if (!send)
{
// what to do if none are set...
}
|
Ideas to send the result of a SQL Select as MailMessage body in ASP.NET MailMessage Class
By : Anthony Greene
Date : March 29 2020, 07:55 AM
wish of those help You can loop the results in a SqlDataReader and add the titles to a string. code :
//create a stringbuilder
StringBuilder sb = new StringBuilder();
//create a connection to the database
using (SqlConnection connection = new SqlConnection(Common.connectionString))
using (SqlCommand command = new SqlCommand("SELECT TITLES FROM DOCUMENTS WHERE AC_DATE = GETDATE()", connection))
{
//open the connection
connection.Open();
//create a reader
SqlDataReader reader = command.ExecuteReader();
//loop all the rows in the database
while (reader.Read())
{
//add the title to the stringbuilder
sb.AppendLine(reader["TITLES"].ToString());
}
}
//create the mail message with the titles
mailMessage.Body = sb.ToString();
|