[Mono-bugs] [Bug 527177] missing body encoding in mail

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Jul 31 11:53:31 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=527177

User krejcif at gmail.com added comment
http://bugzilla.novell.com/show_bug.cgi?id=527177#c2





--- Comment #2 from Filip Krejčí <krejcif at gmail.com>  2009-07-31 09:53:31 MDT ---
We have function, which send emails. When the email contains attachement, the
encoding of body mime part is missing, though it's set.


public static void Send(string to,string subject, HtmlGenerator hg,
List<Attachment> attachments)
{
    System.Net.Mail.MailMessage mm;
    try
    {
        mm = new
System.Net.Mail.MailMessage(ConfigurationSettings.AppSettings["EmailSender"].ToString(),
to);
    }
    catch (ArgumentException excp)
    {
        log.Error(msg, excp);
        throw new ArgumentException(msg, excp);
    }
    try
    {
        mm.Body = hg.Serialize();
    }
    catch (Exception excp)
    {
        log.Error(msg, excp);
        throw new Exception(msg, excp);
    }
    mm.BodyEncoding = Encoding.UTF8;
    mm.IsBodyHtml = true;
    mm.Subject = subject;
    mm.SubjectEncoding = Encoding.UTF8;

    if (attachments != null && attachments.Count > 0)
    {
        int i = 0;
        foreach (Attachment item in attachments)
        {
            item.Name = "attachment" + i.ToString() +
Path.GetExtension(item.Name);
            item.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;
            item.NameEncoding = Encoding.UTF8;
            mm.Attachments.Add(item);
            i++;
        }
    }

    SmtpClient client = new
SmtpClient(ConfigurationSettings.AppSettings["SmtpServerAddress"].ToString());

    try
    {
        client.Send(mm);
    }
    catch (SmtpException excp)
    {
        log.Error(msg, excp);
        throw new SmtpException(msg, excp);
    }
    catch (Exception excp)
    {
        log.Error(msg, excp);
        throw new Exception(msg, excp);
    }
}

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list