logo
down
shadow

What does MailMessage.IsBodyHtml do?


What does MailMessage.IsBodyHtml do?

By : user3860820
Date : January 02 2021, 06:48 AM
seems to work fine I'm testing sending out some emails via C#, but I can't tell what effect setting IsBodyHtml to true has. Regardless of the value, whatever I send in my Body shows up with a content type of "text/plain", and my HTML shows up tags and all in my email client (gmail). What is that flag actually supposed to do? , Here is an excerpt for my SMTP helper I use everyday....
code :


Share : facebook icon twitter icon
How to convert OpenPop.NET MailMessage to System.Net.Mail.MailMessage?

How to convert OpenPop.NET MailMessage to System.Net.Mail.MailMessage?


By : user2616037
Date : March 29 2020, 07:55 AM
hop of those help? If you are using OpenPop.NET >=version 2, you could just call the ToMailMessage method that accompanies the Message class.
ASP.NET MailMessage.BodyEncoding and MailMessage.SubjectEncoding defaults

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

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)

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

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();
shadow
Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk