+1 vote

I must to send an e-mail and email attachment using
Content-Transfer-Encoding: base64

Can you shoe me an example?

by

1 Answer

0 votes
 
Best answer

Content-Transfer-Encoding email header is set by Mail.dll automatically.

You can overwrite it using MimeData.ContentTransferEncoding property.

Use builder class to create s new email message:

MailBuilder builder = new MailBuilder();
builder.From.Add(new MailBox("alice@example.com", "Alice"));
builder.To.Add(new MailBox("bob@example.com", "Bob"));
builder.Subject = "Test";
builder.Text = "This is plain text message.";

MimeData attachment = builder.AddAttachment(@"c:\image.jpeg");

attachment.ContentTransferEncoding = MimeEncoding.Base64;

IMail email = builder.Create();

Finally send the message:

using (Smtp smtp = new Smtp())
{
      smtp.ConnectSSL("server.example.com");
      smtp.UseBestLogin("user", "password");

      smtp.SendMessage(email);

      smtp.Close();
}
by (301k points)
...